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

pub struct Disconnect;

#[mullvad_management_interface::async_trait]
impl Command for Disconnect {
    fn name(&self) -> &'static str {
        "disconnect"
    }

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

    async fn run(&self, _: &clap::ArgMatches<'_>) -> Result<()> {
        let mut rpc = new_rpc_client().await?;
        rpc.disconnect_tunnel(()).await?;
        Ok(())
    }
}