diff options
| author | Emīls Piņķis <pinkisemils@gmail.com> | 2018-03-22 17:12:35 +0000 |
|---|---|---|
| committer | Emīls Piņķis <pinkisemils@gmail.com> | 2018-03-26 15:24:43 +0100 |
| commit | 89231c92ec1f9c8fcfb7b6731fbcf046f8d2278c (patch) | |
| tree | acec71db25e722b27fc8fa1c2803224daaf9ed64 /mullvad-cli/src | |
| parent | 88079a228309a7cc9abe20aaaab762f9900f4ba1 (diff) | |
| download | mullvadvpn-89231c92ec1f9c8fcfb7b6731fbcf046f8d2278c.tar.xz mullvadvpn-89231c92ec1f9c8fcfb7b6731fbcf046f8d2278c.zip | |
Add version subcommand to CLI
Diffstat (limited to 'mullvad-cli/src')
| -rw-r--r-- | mullvad-cli/src/cmds/mod.rs | 3 | ||||
| -rw-r--r-- | mullvad-cli/src/cmds/version.rs | 29 |
2 files changed, 32 insertions, 0 deletions
diff --git a/mullvad-cli/src/cmds/mod.rs b/mullvad-cli/src/cmds/mod.rs index 4450d9d34f..6de212b7fb 100644 --- a/mullvad-cli/src/cmds/mod.rs +++ b/mullvad-cli/src/cmds/mod.rs @@ -25,6 +25,8 @@ pub use self::lan::Lan; mod tunnel; pub use self::tunnel::Tunnel; +mod version; +pub use self::version::Version; /// Returns a map of all available subcommands with their name as key. pub fn get_commands() -> HashMap<&'static str, Box<Command>> { @@ -37,6 +39,7 @@ pub fn get_commands() -> HashMap<&'static str, Box<Command>> { Box::new(Relay), Box::new(Lan), Box::new(Tunnel), + Box::new(Version), ]; let mut map = HashMap::new(); for cmd in commands { diff --git a/mullvad-cli/src/cmds/version.rs b/mullvad-cli/src/cmds/version.rs new file mode 100644 index 0000000000..b1b5330bb1 --- /dev/null +++ b/mullvad-cli/src/cmds/version.rs @@ -0,0 +1,29 @@ +use {Command, Result}; +use clap; + +use mullvad_types::version; +use rpc; + +pub struct Version; + +impl Command for Version { + fn name(&self) -> &'static str { + "version" + } + + fn clap_subcommand(&self) -> clap::App<'static, 'static> { + clap::SubCommand::with_name(self.name()) + .about("Shows current version, and the currently supported versions") + } + + fn run(&self, _: &clap::ArgMatches) -> Result<()> { + let current_version: String = rpc::call("get_current_version", &[] as &[u8; 0])?; + println!("Current version: {}", current_version); + let version_info: version::AppVersionInfo = rpc::call("get_version_info", &[] as &[u8; 0])?; + println!("Supported: {}", version_info.current_is_supported); + println!("Latest releases:"); + println!("\tlatest stable: {}", version_info.latest.latest_stable); + println!("\tlatest: {}", version_info.latest.latest); + Ok(()) + } +} |
