]> git.proxmox.com Git - pmg-log-tracker.git/commitdiff
update clap from 2 to 3
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Thu, 24 Nov 2022 17:47:03 +0000 (18:47 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Thu, 24 Nov 2022 17:47:12 +0000 (18:47 +0100)
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 <t.lamprecht@proxmox.com>
Cargo.toml
debian/control
src/main.rs

index 709669a6efb51ae573a1c14b065b35975e44dfdb..436d5325bf2e7ef697cd346c88f98bbfbc106d38 100644 (file)
@@ -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"
index 5da0e3db735bda8ac387431be14b60ae6fef7911..06c8e007f6fee07cba4b3898cf02b41ac9f5a48a 100644 (file)
@@ -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 <support@proxmox.com>
 Standards-Version: 4.5.1
index 1b32b6d8b55a4543f1a34a1c80aceda65fc90dcc..3306577c32b0f5a952099dcd280cbb67cf32cb6b 100644 (file)
@@ -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::<u8>("verbose").copied().unwrap_or(0) as _;
 
         if let Some(string_match) = args.value_of("search") {
             self.options.string_match = string_match.to_string();