diff options
| author | Linus Färnstrand <linus@mullvad.net> | 2017-10-18 13:49:36 +0200 |
|---|---|---|
| committer | Linus Färnstrand <linus@mullvad.net> | 2017-10-18 14:38:56 +0200 |
| commit | f9c7cb281fde9974e71233a386de7375e31c0c05 (patch) | |
| tree | bd7c2ca2de5667767ca6e02c30d069d01ebe1b54 /mullvad-cli/src | |
| parent | 7468c729f28d03ac036a533dae80ab764b23d688 (diff) | |
| download | mullvadvpn-f9c7cb281fde9974e71233a386de7375e31c0c05.tar.xz mullvadvpn-f9c7cb281fde9974e71233a386de7375e31c0c05.zip | |
Add shutdown command to cli
Diffstat (limited to 'mullvad-cli/src')
| -rw-r--r-- | mullvad-cli/src/cmds/mod.rs | 4 | ||||
| -rw-r--r-- | mullvad-cli/src/cmds/shutdown.rs | 21 |
2 files changed, 25 insertions, 0 deletions
diff --git a/mullvad-cli/src/cmds/mod.rs b/mullvad-cli/src/cmds/mod.rs index 8061344b96..0104185543 100644 --- a/mullvad-cli/src/cmds/mod.rs +++ b/mullvad-cli/src/cmds/mod.rs @@ -16,6 +16,9 @@ pub use self::disconnect::Disconnect; mod custom_relay; pub use self::custom_relay::CustomRelay; +mod shutdown; +pub use self::shutdown::Shutdown; + /// Returns a map of all available subcommands with their name as key. pub fn get_commands() -> HashMap<&'static str, Box<Command>> { let commands: Vec<Box<Command>> = vec![ @@ -24,6 +27,7 @@ pub fn get_commands() -> HashMap<&'static str, Box<Command>> { Box::new(Connect), Box::new(Disconnect), Box::new(CustomRelay), + Box::new(Shutdown), ]; let mut map = HashMap::new(); for cmd in commands { diff --git a/mullvad-cli/src/cmds/shutdown.rs b/mullvad-cli/src/cmds/shutdown.rs new file mode 100644 index 0000000000..bb211bed84 --- /dev/null +++ b/mullvad-cli/src/cmds/shutdown.rs @@ -0,0 +1,21 @@ +use {Command, Result}; +use clap; + +use mullvad_types::account::{AccountData, AccountToken}; +use rpc; + +pub struct Shutdown; + +impl Command for Shutdown { + fn name(&self) -> &'static str { + "shutdown" + } + + fn clap_subcommand(&self) -> clap::App<'static, 'static> { + clap::SubCommand::with_name(self.name()).about("Makes the backend daemon quit") + } + + fn run(&self, _matches: &clap::ArgMatches) -> Result<()> { + rpc::call("shutdown", &[] as &[u8; 0]) + } +} |
