summaryrefslogtreecommitdiffhomepage
path: root/mullvad-cli/src/cmds/reconnect.rs
blob: 0cc7f6bfea7df4a3c3fe6e809529dd0eaf3f5791 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
use crate::{new_rpc_client, Command, Result};
use talpid_types::ErrorExt;

pub struct Reconnect;

impl Command for Reconnect {
    fn name(&self) -> &'static str {
        "reconnect"
    }

    fn clap_subcommand(&self) -> clap::App<'static, 'static> {
        clap::SubCommand::with_name(self.name()).about("Command the client to reconnect")
    }

    fn run(&self, _matches: &clap::ArgMatches<'_>) -> Result<()> {
        let mut rpc = new_rpc_client()?;
        if let Err(e) = rpc.reconnect() {
            eprintln!("{}", e.display_chain());
        }
        Ok(())
    }
}