diff options
| author | Oskar Nyberg <oskar@mullvad.net> | 2022-04-08 15:12:30 +0200 |
|---|---|---|
| committer | Oskar Nyberg <oskar@mullvad.net> | 2022-04-08 15:12:30 +0200 |
| commit | 6a10c449e02a7a4d4614801875e3c975dc95f0ca (patch) | |
| tree | 0dba8c6d4649a7aa5cd7528ec03b4bbb87f9eb0f | |
| parent | 72a5398a5212a0df98d6a1ca0357817abd3cc508 (diff) | |
| parent | f123afb61fee36293808fade6bba89c54458d471 (diff) | |
| download | mullvadvpn-6a10c449e02a7a4d4614801875e3c975dc95f0ca.tar.xz mullvadvpn-6a10c449e02a7a4d4614801875e3c975dc95f0ca.zip | |
Merge branch 'add-verbose-mode-for-tunnel-state-status'
| -rw-r--r-- | mullvad-cli/src/cmds/status.rs | 44 |
1 files changed, 26 insertions, 18 deletions
diff --git a/mullvad-cli/src/cmds/status.rs b/mullvad-cli/src/cmds/status.rs index 69052dcaf1..3d5cfc8b7d 100644 --- a/mullvad-cli/src/cmds/status.rs +++ b/mullvad-cli/src/cmds/status.rs @@ -20,35 +20,43 @@ impl Command for Status { .short('l') .help("Prints the current location and IP. Based on GeoIP lookups"), ) - .subcommand( - clap::App::new("listen") - .about("Listen for VPN tunnel state changes") - .arg( - clap::Arg::new("verbose") - .short('v') - .help("Enables verbose output"), - ), + .arg( + clap::Arg::new("debug") + .long("debug") + .global(true) + .help("Enables verbose output"), ) + .subcommand(clap::App::new("listen").about("Listen for VPN tunnel state changes")) } async fn run(&self, matches: &clap::ArgMatches) -> Result<()> { + let debug = matches.is_present("debug"); + let mut rpc = new_rpc_client().await?; let state = rpc.get_tunnel_state(()).await?.into_inner(); - format::print_state(&state); + if debug { + println!("Tunnel state: {:#?}", state); + } else { + format::print_state(&state); + } + if matches.is_present("location") { print_location(&mut rpc).await?; } - if let Some(listen_matches) = matches.subcommand_matches("listen") { - let verbose = listen_matches.is_present("verbose"); - + if matches.subcommand_matches("listen").is_some() { let mut events = rpc.events_listen(()).await?.into_inner(); while let Some(event) = events.message().await? { match event.event.unwrap() { EventType::TunnelState(new_state) => { - format::print_state(&new_state); + if debug { + println!("New tunnel state: {:#?}", new_state); + } else { + format::print_state(&new_state); + } + use mullvad_management_interface::types::tunnel_state::State::*; match new_state.state.unwrap() { Connected(..) | Disconnected(..) => { @@ -60,27 +68,27 @@ impl Command for Status { } } EventType::Settings(settings) => { - if verbose { + if debug { println!("New settings: {:#?}", settings); } } EventType::RelayList(relay_list) => { - if verbose { + if debug { println!("New relay list: {:#?}", relay_list); } } EventType::VersionInfo(app_version_info) => { - if verbose { + if debug { println!("New app version info: {:#?}", app_version_info); } } EventType::Device(device) => { - if verbose { + if debug { println!("Device event: {:#?}", device); } } EventType::RemoveDevice(device) => { - if verbose { + if debug { println!("Remove device event: {:#?}", device); } } |
