client, server: make clap's helptext a bit friendlier

pull/96/head
Jake McGinty 2021-05-26 14:23:02 +09:00
parent ec210f9468
commit 9524019c55
2 changed files with 8 additions and 7 deletions

View File

@ -14,7 +14,7 @@ use std::{
thread, thread,
time::{Duration, SystemTime}, time::{Duration, SystemTime},
}; };
use structopt::StructOpt; use structopt::{clap::AppSettings, StructOpt};
use wgctrl::{Device, DeviceUpdate, InterfaceName, PeerConfigBuilder, PeerInfo}; use wgctrl::{Device, DeviceUpdate, InterfaceName, PeerConfigBuilder, PeerInfo};
mod data_store; mod data_store;
@ -37,13 +37,14 @@ macro_rules! println_pad {
} }
#[derive(Debug, StructOpt)] #[derive(Debug, StructOpt)]
#[structopt(name = "innernet", about)] #[structopt(name = "innernet", about, global_settings(&[AppSettings::ColoredHelp, AppSettings::DeriveDisplayOrder, AppSettings::VersionlessSubcommands, AppSettings::UnifiedHelpMessage]))]
struct Opts { struct Opts {
#[structopt(subcommand)] #[structopt(subcommand)]
command: Option<Command>, command: Option<Command>,
#[structopt(short, parse(from_occurrences))] /// Verbose output, use -vv for even higher verbositude.
verbosity: u64, #[structopt(short, long, parse(from_occurrences))]
verbose: u64,
#[structopt(flatten)] #[structopt(flatten)]
network: NetworkOpt, network: NetworkOpt,
@ -981,7 +982,7 @@ fn print_peer(peer: &PeerState, short: bool, level: usize) {
fn main() { fn main() {
let opt = Opts::from_args(); let opt = Opts::from_args();
util::init_logger(opt.verbosity); util::init_logger(opt.verbose);
if let Err(e) = run(opt) { if let Err(e) = run(opt) {
println!(); println!();

View File

@ -22,7 +22,7 @@ use std::{
sync::Arc, sync::Arc,
time::Duration, time::Duration,
}; };
use structopt::StructOpt; use structopt::{clap::AppSettings, StructOpt};
use subtle::ConstantTimeEq; use subtle::ConstantTimeEq;
use wgctrl::{Backend, Device, DeviceUpdate, InterfaceName, Key, PeerConfigBuilder}; 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"); pub const VERSION: &str = env!("CARGO_PKG_VERSION");
#[derive(Debug, StructOpt)] #[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 { struct Opt {
#[structopt(subcommand)] #[structopt(subcommand)]
command: Command, command: Command,