summaryrefslogtreecommitdiffhomepage
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
parentbc9797e5e5f08cb023d746a69077c171b16cec98 (diff)
downloadmullvadvpn-a4c4c5271e9ca5e29373b8e745e785d6f5ccbfd8.tar.xz
mullvadvpn-a4c4c5271e9ca5e29373b8e745e785d6f5ccbfd8.zip
Add CLI subcommand to create new accounts
-rw-r--r--mullvad-cli/src/cmds/account.rs13
-rw-r--r--mullvad-ipc-client/src/lib.rs4
2 files changed, 17 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()
+ }
}
diff --git a/mullvad-ipc-client/src/lib.rs b/mullvad-ipc-client/src/lib.rs
index fe8a9b0645..a962355ce8 100644
--- a/mullvad-ipc-client/src/lib.rs
+++ b/mullvad-ipc-client/src/lib.rs
@@ -99,6 +99,10 @@ impl DaemonRpcClient {
self.call("disconnect", &NO_ARGS)
}
+ pub fn create_new_account(&mut self) -> Result<()> {
+ self.call("create_new_account", &NO_ARGS)
+ }
+
pub fn get_account(&mut self) -> Result<Option<AccountToken>> {
self.call("get_account", &NO_ARGS)
}