summaryrefslogtreecommitdiffhomepage
path: root/mullvad-cli
diff options
context:
space:
mode:
authorLinus Färnstrand <linus@mullvad.net>2017-09-27 15:38:10 +0200
committerLinus Färnstrand <linus@mullvad.net>2017-09-27 15:38:10 +0200
commit86d3f4746e56a5b3db0ca0afe7fb017e5db0fc4c (patch)
tree7866a6014cbc5a66faad5decf0213a9d7cad3cb9 /mullvad-cli
parented4bc11810888e19974c4770e8cd8ad73376cafe (diff)
downloadmullvadvpn-86d3f4746e56a5b3db0ca0afe7fb017e5db0fc4c.tar.xz
mullvadvpn-86d3f4746e56a5b3db0ca0afe7fb017e5db0fc4c.zip
Add command to unset account via CLI
Diffstat (limited to 'mullvad-cli')
-rw-r--r--mullvad-cli/src/cmds/account.rs14
1 files changed, 11 insertions, 3 deletions
diff --git a/mullvad-cli/src/cmds/account.rs b/mullvad-cli/src/cmds/account.rs
index 0dda601fc9..854ce8fc91 100644
--- a/mullvad-cli/src/cmds/account.rs
+++ b/mullvad-cli/src/cmds/account.rs
@@ -28,12 +28,18 @@ impl Command for Account {
clap::SubCommand::with_name("get")
.about("Display information about the currently configured account"),
)
+ .subcommand(
+ clap::SubCommand::with_name("unset")
+ .about("Removes the account number from the settings"),
+ )
}
fn run(&self, matches: &clap::ArgMatches) -> Result<()> {
if let Some(set_matches) = matches.subcommand_matches("set") {
let token = value_t_or_exit!(set_matches.value_of("token"), String);
- self.set(&token)
+ self.set(Some(&token))
+ } else if let Some(_matches) = matches.subcommand_matches("unset") {
+ self.set(None)
} else if let Some(_matches) = matches.subcommand_matches("get") {
self.get()
} else {
@@ -43,9 +49,11 @@ impl Command for Account {
}
impl Account {
- fn set(&self, token: &str) -> Result<()> {
- rpc::call("set_account", &[token]).map(|_: Option<()>| {
+ fn set(&self, token: Option<&str>) -> Result<()> {
+ rpc::call("set_account", &[token]).map(|_: Option<()>| if let Some(token) = token {
println!("Mullvad account \"{}\" set", token);
+ } else {
+ println!("Mullvad account removed");
})
}