Add back the check command
This commit is contained in:
parent
f663a4f8b4
commit
ebccc59bf0
2 changed files with 34 additions and 3 deletions
18
src/main.rs
18
src/main.rs
|
|
@ -41,6 +41,9 @@ struct ConfigOpts {
|
|||
|
||||
#[derive(Subcommand, Debug)]
|
||||
enum Command {
|
||||
/// Checks connection status
|
||||
Check,
|
||||
|
||||
/// Prints the list of VPN endpoints
|
||||
Locations,
|
||||
|
||||
|
|
@ -52,12 +55,27 @@ fn main() -> Result<(), anyhow::Error> {
|
|||
env_logger::init();
|
||||
let opts = Opts::parse();
|
||||
match &opts.command {
|
||||
Command::Check => check(&opts)?,
|
||||
Command::Locations => list_locations(&opts)?,
|
||||
Command::Config(get_config_opts) => get_config(&opts, get_config_opts)?,
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn check(opts: &Opts) -> Result<(), anyhow::Error> {
|
||||
let check_result = api::check()?;
|
||||
if opts.json {
|
||||
println!("{}", serde_json::to_string(&check_result)?);
|
||||
} else {
|
||||
println!("Connected: {}", check_result.connected);
|
||||
println!("Ip: {}", check_result.ip);
|
||||
if let Some(location) = check_result.location {
|
||||
println!("Location: {}", location);
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn list_locations(opts: &Opts) -> Result<(), anyhow::Error> {
|
||||
let locations = api::get_locations()?;
|
||||
if opts.json {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue