summaryrefslogtreecommitdiffhomepage
path: root/mullvad-cli/src/cmds
diff options
context:
space:
mode:
authorLinus Färnstrand <linus@mullvad.net>2017-10-18 17:35:00 +0200
committerLinus Färnstrand <linus@mullvad.net>2017-10-18 17:35:00 +0200
commitb92ef2951393555009fcfe4030a62979bdbcbdac (patch)
tree147190e526692251e066baecf5f3a59391b14fd8 /mullvad-cli/src/cmds
parentd7a0a68987223f994b6cb30fad79b9454d99def7 (diff)
parente1f41bb918aedb3c4af06ad505e80bf28db99462 (diff)
downloadmullvadvpn-b92ef2951393555009fcfe4030a62979bdbcbdac.tar.xz
mullvadvpn-b92ef2951393555009fcfe4030a62979bdbcbdac.zip
Merge branch 'add-shutdown-rpc-method'
Diffstat (limited to 'mullvad-cli/src/cmds')
-rw-r--r--mullvad-cli/src/cmds/mod.rs4
-rw-r--r--mullvad-cli/src/cmds/shutdown.rs20
2 files changed, 24 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..4a334da5a5
--- /dev/null
+++ b/mullvad-cli/src/cmds/shutdown.rs
@@ -0,0 +1,20 @@
+use {Command, Result};
+use clap;
+
+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])
+ }
+}