diff options
| author | Linus Färnstrand <linus@mullvad.net> | 2017-09-27 15:57:14 +0200 |
|---|---|---|
| committer | Linus Färnstrand <linus@mullvad.net> | 2017-09-27 15:57:14 +0200 |
| commit | 6179d6c18cd9e508b7341d5a28e4f9f987043b66 (patch) | |
| tree | 891f110f516e01a9187343b3ed27046418748db2 /mullvad-cli/src | |
| parent | ed4bc11810888e19974c4770e8cd8ad73376cafe (diff) | |
| parent | 0db3894b92a0d78703791c45fea581567e7b15bc (diff) | |
| download | mullvadvpn-6179d6c18cd9e508b7341d5a28e4f9f987043b66.tar.xz mullvadvpn-6179d6c18cd9e508b7341d5a28e4f9f987043b66.zip | |
Merge branch 'improve-unsetting-account-number'2017.1-beta2
Diffstat (limited to 'mullvad-cli/src')
| -rw-r--r-- | mullvad-cli/src/cmds/account.rs | 14 |
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"); }) } |
