From 3e6542d819fd550e675ee0b59d7b5de7b361677a Mon Sep 17 00:00:00 2001 From: Thomas Lamprecht Date: Thu, 24 Nov 2022 18:47:03 +0100 Subject: [PATCH 1/1] update clap from 2 to 3 only relevant change is the assertion that multiple(true) takes a value, so we need to change to the new actions system. Note that with 3.2.20+ we could switch to args.get_count("verbose") saving us the unwrap/dereference dance. Signed-off-by: Thomas Lamprecht --- Cargo.toml | 2 +- debian/control | 6 +++--- src/main.rs | 31 +++++++++++++++---------------- 3 files changed, 19 insertions(+), 20 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 709669a..436d532 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,6 +11,6 @@ exclude = [ "build", "debian" ] [dependencies] anyhow = "1" -clap = "2.33" +clap = { version = "3.2", features = ["cargo"] } flate2 = "1.0" libc = "0.2" diff --git a/debian/control b/debian/control index 5da0e3d..06c8e00 100644 --- a/debian/control +++ b/debian/control @@ -7,10 +7,10 @@ Build-Depends: debhelper (>= 12), rustc:native, libstd-rust-dev, librust-anyhow-1+default-dev, - librust-clap-2+default-dev (>= 2.32-~~), + librust-clap-3+cargo-dev (>= 3.2-~~), + librust-clap-3+default-dev (>= 3.2-~~), librust-flate2-1+default-dev, - librust-libc-0.2+default-dev (>= 0.2.48-~~), - librust-time-0.1+default-dev (>= 0.1.42-~~), + librust-libc-0.2+default-dev, faketime Maintainer: Proxmox Support Team Standards-Version: 4.5.1 diff --git a/src/main.rs b/src/main.rs index 1b32b6d..3306577 100644 --- a/src/main.rs +++ b/src/main.rs @@ -24,64 +24,63 @@ fn main() -> Result<(), Error> { .about(clap::crate_description!()) .arg( Arg::with_name("verbose") - .short("v") + .short('v') .long("verbose") .help("Verbose output, can be specified multiple times") - .multiple(true) - .takes_value(false), + .action(clap::ArgAction::Count), ) .arg( Arg::with_name("inputfile") - .short("i") + .short('i') .long("inputfile") .help("Input file to use instead of /var/log/syslog, or '-' for stdin") .value_name("INPUTFILE"), ) .arg( Arg::with_name("host") - .short("h") + .short('h') .long("host") .help("Hostname or Server IP") .value_name("HOST"), ) .arg( Arg::with_name("from") - .short("f") + .short('f') .long("from") .help("Mails from SENDER") .value_name("SENDER"), ) .arg( Arg::with_name("to") - .short("t") + .short('t') .long("to") .help("Mails to RECIPIENT") .value_name("RECIPIENT"), ) .arg( Arg::with_name("start") - .short("s") + .short('s') .long("starttime") .help("Start time (YYYY-MM-DD HH:MM:SS) or seconds since epoch") .value_name("TIME"), ) .arg( Arg::with_name("end") - .short("e") + .short('e') .long("endtime") .help("End time (YYYY-MM-DD HH:MM:SS) or seconds since epoch") .value_name("TIME"), ) .arg( Arg::with_name("msgid") - .short("m") + .short('m') .long("message-id") .help("Message ID (exact match)") .value_name("MSGID"), ) .arg( Arg::with_name("qids") - .short("q") + .short('q') .long("queue-id") .help("Queue ID (exact match), can be specified multiple times") .value_name("QID") @@ -90,14 +89,14 @@ fn main() -> Result<(), Error> { ) .arg( Arg::with_name("search") - .short("x") + .short('x') .long("search-string") .help("Search for string") .value_name("STRING"), ) .arg( Arg::with_name("limit") - .short("l") + .short('l') .long("limit") .help("Print MAX entries") .value_name("MAX") @@ -105,13 +104,13 @@ fn main() -> Result<(), Error> { ) .arg( Arg::with_name("exclude_greylist") - .short("g") + .short('g') .long("exclude-greylist") .help("Exclude greylist entries"), ) .arg( Arg::with_name("exclude_ndr") - .short("n") + .short('n') .long("exclude-ndr") .help("Exclude NDR entries"), ) @@ -2043,7 +2042,7 @@ impl Parser { self.options.exclude_greylist = args.is_present("exclude_greylist"); self.options.exclude_ndr = args.is_present("exclude_ndr"); - self.options.verbose = args.occurrences_of("verbose") as _; + self.options.verbose = args.get_one::("verbose").copied().unwrap_or(0) as _; if let Some(string_match) = args.value_of("search") { self.options.string_match = string_match.to_string(); -- 2.39.2