From 9524019c55e79341d61fa9374b0e3fe136045699 Mon Sep 17 00:00:00 2001 From: Jake McGinty Date: Wed, 26 May 2021 14:23:02 +0900 Subject: [PATCH] client, server: make clap's helptext a bit friendlier --- client/src/main.rs | 11 ++++++----- server/src/main.rs | 4 ++-- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/client/src/main.rs b/client/src/main.rs index 98e5627..8e5cbed 100644 --- a/client/src/main.rs +++ b/client/src/main.rs @@ -14,7 +14,7 @@ use std::{ thread, time::{Duration, SystemTime}, }; -use structopt::StructOpt; +use structopt::{clap::AppSettings, StructOpt}; use wgctrl::{Device, DeviceUpdate, InterfaceName, PeerConfigBuilder, PeerInfo}; mod data_store; @@ -37,13 +37,14 @@ macro_rules! println_pad { } #[derive(Debug, StructOpt)] -#[structopt(name = "innernet", about)] +#[structopt(name = "innernet", about, global_settings(&[AppSettings::ColoredHelp, AppSettings::DeriveDisplayOrder, AppSettings::VersionlessSubcommands, AppSettings::UnifiedHelpMessage]))] struct Opts { #[structopt(subcommand)] command: Option, - #[structopt(short, parse(from_occurrences))] - verbosity: u64, + /// Verbose output, use -vv for even higher verbositude. + #[structopt(short, long, parse(from_occurrences))] + verbose: u64, #[structopt(flatten)] network: NetworkOpt, @@ -981,7 +982,7 @@ fn print_peer(peer: &PeerState, short: bool, level: usize) { fn main() { let opt = Opts::from_args(); - util::init_logger(opt.verbosity); + util::init_logger(opt.verbose); if let Err(e) = run(opt) { println!(); diff --git a/server/src/main.rs b/server/src/main.rs index c04a6f3..da43f4d 100644 --- a/server/src/main.rs +++ b/server/src/main.rs @@ -22,7 +22,7 @@ use std::{ sync::Arc, time::Duration, }; -use structopt::StructOpt; +use structopt::{clap::AppSettings, StructOpt}; use subtle::ConstantTimeEq; use wgctrl::{Backend, Device, DeviceUpdate, InterfaceName, Key, PeerConfigBuilder}; @@ -44,7 +44,7 @@ pub use shared::{Association, AssociationContents}; pub const VERSION: &str = env!("CARGO_PKG_VERSION"); #[derive(Debug, StructOpt)] -#[structopt(name = "innernet-server", about)] +#[structopt(name = "innernet-server", about, global_settings(&[AppSettings::ColoredHelp, AppSettings::DeriveDisplayOrder, AppSettings::VersionlessSubcommands, AppSettings::UnifiedHelpMessage]))] struct Opt { #[structopt(subcommand)] command: Command,