summaryrefslogtreecommitdiffhomepage
path: root/mullvad-cli/src
diff options
context:
space:
mode:
authorEmīls Piņķis <emils@mullvad.net>2019-10-02 18:41:59 +0100
committerEmīls Piņķis <emils@mullvad.net>2019-10-04 13:11:28 +0100
commita4c4c5271e9ca5e29373b8e745e785d6f5ccbfd8 (patch)
tree2ad34a62711dc3a7f4e977d5b973316324bb542d /mullvad-cli/src
parentbc9797e5e5f08cb023d746a69077c171b16cec98 (diff)
downloadmullvadvpn-a4c4c5271e9ca5e29373b8e745e785d6f5ccbfd8.tar.xz
mullvadvpn-a4c4c5271e9ca5e29373b8e745e785d6f5ccbfd8.zip
Add CLI subcommand to create new accounts
Diffstat (limited to 'mullvad-cli/src')
-rw-r--r--mullvad-cli/src/cmds/account.rs13
1 files changed, 13 insertions, 0 deletions
diff --git a/mullvad-cli/src/cmds/account.rs b/mullvad-cli/src/cmds/account.rs
index 5123f0a8f8..13de5db554 100644
--- a/mullvad-cli/src/cmds/account.rs
+++ b/mullvad-cli/src/cmds/account.rs
@@ -30,6 +30,10 @@ impl Command for Account {
clap::SubCommand::with_name("unset")
.about("Removes the account number from the settings"),
)
+ .subcommand(
+ clap::SubCommand::with_name("create")
+ .about("Creates a new account and sets it as the active one"),
+ )
}
fn run(&self, matches: &clap::ArgMatches<'_>) -> Result<()> {
@@ -40,6 +44,8 @@ impl Command for Account {
self.set(None)
} else if let Some(_matches) = matches.subcommand_matches("get") {
self.get()
+ } else if let Some(_matches) = matches.subcommand_matches("create") {
+ self.create()
} else {
unreachable!("No account command given");
}
@@ -70,4 +76,11 @@ impl Account {
}
Ok(())
}
+
+ fn create(&self) -> Result<()> {
+ let mut rpc = new_rpc_client()?;
+ rpc.create_new_account()?;
+ println!("New account created!");
+ self.get()
+ }
}