From: Ian Jackson Date: Thu, 15 Jun 2023 18:41:41 +0000 (+0100) Subject: clap: Use ArgAction::Count for debug level X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ian/git?a=commitdiff_plain;h=92cd28d2c0412a49aba653b9f0968d2bc4431285;p=hippotat.git clap: Use ArgAction::Count for debug level Removes a deprecation warning (this is recommended by the clap 3 to 4 migration guide). Checking hippotat v1.1.7 (/volatile/rustcargo/Rustup/Hippotat/hippotat) warning: use of deprecated function `::augment_args::parse_from_occurrences`: Replaced with `#[clap(action = ArgAction::Count)]` with a field type of `u8` --> src/reporter.rs:18:33 | 18 | #[clap(long, short='D', parse(from_occurrences))] | ^^^^^^^^^^^^^^^^ | = note: `#[warn(deprecated)]` on by default Signed-off-by: Ian Jackson --- diff --git a/src/reporter.rs b/src/reporter.rs index e12c6d2..cc2d098 100644 --- a/src/reporter.rs +++ b/src/reporter.rs @@ -15,8 +15,8 @@ pub struct LogOpts { /// and two -`D` means to send to syslog even messages from lower layers /// (normally just the hippotat modules log to /// syslog). - #[clap(long, short='D', parse(from_occurrences))] - debug: usize, + #[clap(long, short='D', action=clap::ArgAction::Count)] + debug: u8, /// Syslog facility to use #[clap(long, parse(try_from_str=parse_syslog_facility))] @@ -30,7 +30,7 @@ fn parse_syslog_facility(s: &str) -> syslog::Facility { #[derive(Debug)] struct LogWrapper{ - debug: usize, + debug: u8, output: T, } @@ -112,7 +112,7 @@ impl LogOpts { logb.filter(Some("hippotat"), *[ log::LevelFilter::Info, log::LevelFilter::Debug ] - .get(self.debug) + .get(usize::from(self.debug)) .unwrap_or( &log::LevelFilter::Trace ));