summaryrefslogtreecommitdiffhomepage
path: root/mullvad-cli/src/cmds
diff options
context:
space:
mode:
authorEmīls <emils@mullvad.net>2022-04-28 14:50:42 +0100
committerEmīls <emils@mullvad.net>2022-05-05 10:16:17 +0100
commitba95533d864ec2ba0de6fc8284fa53841a55e8bb (patch)
tree969bab227f7ccdd97830f5c8c5bee584f0fe1987 /mullvad-cli/src/cmds
parent3a19900e51ca874e8202bfbd2853662a0652863e (diff)
downloadmullvadvpn-ba95533d864ec2ba0de6fc8284fa53841a55e8bb.tar.xz
mullvadvpn-ba95533d864ec2ba0de6fc8284fa53841a55e8bb.zip
Rework output of status subcommand in CLI
The output of the status command is reworked to show hostnames instead of IP addresses and trim the fat. The extra information (tunnel protocols, IP addrresses) are now available with the verbose flag.
Diffstat (limited to 'mullvad-cli/src/cmds')
-rw-r--r--mullvad-cli/src/cmds/connect.rs2
-rw-r--r--mullvad-cli/src/cmds/disconnect.rs2
-rw-r--r--mullvad-cli/src/cmds/reconnect.rs2
-rw-r--r--mullvad-cli/src/cmds/status.rs26
4 files changed, 15 insertions, 17 deletions
diff --git a/mullvad-cli/src/cmds/connect.rs b/mullvad-cli/src/cmds/connect.rs
index a184e38244..3a879fc6a8 100644
--- a/mullvad-cli/src/cmds/connect.rs
+++ b/mullvad-cli/src/cmds/connect.rs
@@ -34,7 +34,7 @@ impl Command for Connect {
if let Some(mut receiver) = receiver_option {
while let Some(state) = receiver.next().await {
let state = state?;
- format::print_state(&state);
+ format::print_state(&state, false);
match state.state.unwrap() {
State::Connected(_) => return Ok(()),
State::Error(_) => return Err(Error::CommandFailed("connect")),
diff --git a/mullvad-cli/src/cmds/disconnect.rs b/mullvad-cli/src/cmds/disconnect.rs
index 9ac051ca57..a906eed22d 100644
--- a/mullvad-cli/src/cmds/disconnect.rs
+++ b/mullvad-cli/src/cmds/disconnect.rs
@@ -34,7 +34,7 @@ impl Command for Disconnect {
if let Some(mut receiver) = receiver_option {
while let Some(state) = receiver.next().await {
let state = state?;
- format::print_state(&state);
+ format::print_state(&state, false);
match state.state.unwrap() {
Disconnected(_) => return Ok(()),
_ => {}
diff --git a/mullvad-cli/src/cmds/reconnect.rs b/mullvad-cli/src/cmds/reconnect.rs
index c2a577a212..53ca666482 100644
--- a/mullvad-cli/src/cmds/reconnect.rs
+++ b/mullvad-cli/src/cmds/reconnect.rs
@@ -34,7 +34,7 @@ impl Command for Reconnect {
if let Some(mut receiver) = receiver_option {
while let Some(state) = receiver.next().await {
let state = state?;
- format::print_state(&state);
+ format::print_state(&state, false);
match state.state.unwrap() {
State::Connected(_) => return Ok(()),
State::Error(_) => return Err(Error::CommandFailed("reconnect")),
diff --git a/mullvad-cli/src/cmds/status.rs b/mullvad-cli/src/cmds/status.rs
index 3d5cfc8b7d..71f31f5fef 100644
--- a/mullvad-cli/src/cmds/status.rs
+++ b/mullvad-cli/src/cmds/status.rs
@@ -15,6 +15,11 @@ impl Command for Status {
clap::App::new(self.name())
.about("View the state of the VPN tunnel")
.arg(
+ clap::Arg::new("verbose")
+ .short('v')
+ .help("Enables verbose output"),
+ )
+ .arg(
clap::Arg::new("location")
.long("location")
.short('l')
@@ -24,13 +29,15 @@ impl Command for Status {
clap::Arg::new("debug")
.long("debug")
.global(true)
- .help("Enables verbose output"),
+ .help("Enables debug 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 verbose = matches.is_present("verbose");
+ let show_full_location = matches.is_present("location");
let mut rpc = new_rpc_client().await?;
let state = rpc.get_tunnel_state(()).await?.into_inner();
@@ -38,10 +45,10 @@ impl Command for Status {
if debug {
println!("Tunnel state: {:#?}", state);
} else {
- format::print_state(&state);
+ format::print_state(&state, verbose);
}
- if matches.is_present("location") {
+ if show_full_location {
print_location(&mut rpc).await?;
}
@@ -54,13 +61,13 @@ impl Command for Status {
if debug {
println!("New tunnel state: {:#?}", new_state);
} else {
- format::print_state(&new_state);
+ format::print_state(&new_state, verbose);
}
use mullvad_management_interface::types::tunnel_state::State::*;
match new_state.state.unwrap() {
Connected(..) | Disconnected(..) => {
- if matches.is_present("location") {
+ if show_full_location {
print_location(&mut rpc).await?;
}
}
@@ -113,9 +120,6 @@ async fn print_location(rpc: &mut ManagementServiceClient) -> Result<()> {
}
}
};
- if !location.hostname.is_empty() {
- println!("Relay: {}", location.hostname);
- }
if !location.ipv4.is_empty() {
println!("IPv4: {}", location.ipv4);
}
@@ -123,12 +127,6 @@ async fn print_location(rpc: &mut ManagementServiceClient) -> Result<()> {
println!("IPv6: {}", location.ipv6);
}
- print!("Location: ");
- if !location.city.is_empty() {
- print!("{}, ", location.city);
- }
- println!("{}", location.country);
-
println!(
"Position: {:.5}°N, {:.5}°W",
location.latitude, location.longitude