summaryrefslogtreecommitdiffhomepage
path: root/mullvad-cli/src/cmds/version.rs
blob: bf754c386afeb782dbce894e5fd1a050a9b2835c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
use clap;
use {Command, Result};

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(())
    }
}