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 <t.lamprecht@proxmox.com>
This commit is contained in:
Thomas Lamprecht 2022-11-24 18:47:03 +01:00
parent 38ad688ccd
commit 3e6542d819
3 changed files with 19 additions and 20 deletions

View File

@ -11,6 +11,6 @@ exclude = [ "build", "debian" ]
[dependencies] [dependencies]
anyhow = "1" anyhow = "1"
clap = "2.33" clap = { version = "3.2", features = ["cargo"] }
flate2 = "1.0" flate2 = "1.0"
libc = "0.2" libc = "0.2"

6
debian/control vendored
View File

@ -7,10 +7,10 @@ Build-Depends: debhelper (>= 12),
rustc:native, rustc:native,
libstd-rust-dev, libstd-rust-dev,
librust-anyhow-1+default-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-flate2-1+default-dev,
librust-libc-0.2+default-dev (>= 0.2.48-~~), librust-libc-0.2+default-dev,
librust-time-0.1+default-dev (>= 0.1.42-~~),
faketime faketime
Maintainer: Proxmox Support Team <support@proxmox.com> Maintainer: Proxmox Support Team <support@proxmox.com>
Standards-Version: 4.5.1 Standards-Version: 4.5.1

View File

@ -24,64 +24,63 @@ fn main() -> Result<(), Error> {
.about(clap::crate_description!()) .about(clap::crate_description!())
.arg( .arg(
Arg::with_name("verbose") Arg::with_name("verbose")
.short("v") .short('v')
.long("verbose") .long("verbose")
.help("Verbose output, can be specified multiple times") .help("Verbose output, can be specified multiple times")
.multiple(true) .action(clap::ArgAction::Count),
.takes_value(false),
) )
.arg( .arg(
Arg::with_name("inputfile") Arg::with_name("inputfile")
.short("i") .short('i')
.long("inputfile") .long("inputfile")
.help("Input file to use instead of /var/log/syslog, or '-' for stdin") .help("Input file to use instead of /var/log/syslog, or '-' for stdin")
.value_name("INPUTFILE"), .value_name("INPUTFILE"),
) )
.arg( .arg(
Arg::with_name("host") Arg::with_name("host")
.short("h") .short('h')
.long("host") .long("host")
.help("Hostname or Server IP") .help("Hostname or Server IP")
.value_name("HOST"), .value_name("HOST"),
) )
.arg( .arg(
Arg::with_name("from") Arg::with_name("from")
.short("f") .short('f')
.long("from") .long("from")
.help("Mails from SENDER") .help("Mails from SENDER")
.value_name("SENDER"), .value_name("SENDER"),
) )
.arg( .arg(
Arg::with_name("to") Arg::with_name("to")
.short("t") .short('t')
.long("to") .long("to")
.help("Mails to RECIPIENT") .help("Mails to RECIPIENT")
.value_name("RECIPIENT"), .value_name("RECIPIENT"),
) )
.arg( .arg(
Arg::with_name("start") Arg::with_name("start")
.short("s") .short('s')
.long("starttime") .long("starttime")
.help("Start time (YYYY-MM-DD HH:MM:SS) or seconds since epoch") .help("Start time (YYYY-MM-DD HH:MM:SS) or seconds since epoch")
.value_name("TIME"), .value_name("TIME"),
) )
.arg( .arg(
Arg::with_name("end") Arg::with_name("end")
.short("e") .short('e')
.long("endtime") .long("endtime")
.help("End time (YYYY-MM-DD HH:MM:SS) or seconds since epoch") .help("End time (YYYY-MM-DD HH:MM:SS) or seconds since epoch")
.value_name("TIME"), .value_name("TIME"),
) )
.arg( .arg(
Arg::with_name("msgid") Arg::with_name("msgid")
.short("m") .short('m')
.long("message-id") .long("message-id")
.help("Message ID (exact match)") .help("Message ID (exact match)")
.value_name("MSGID"), .value_name("MSGID"),
) )
.arg( .arg(
Arg::with_name("qids") Arg::with_name("qids")
.short("q") .short('q')
.long("queue-id") .long("queue-id")
.help("Queue ID (exact match), can be specified multiple times") .help("Queue ID (exact match), can be specified multiple times")
.value_name("QID") .value_name("QID")
@ -90,14 +89,14 @@ fn main() -> Result<(), Error> {
) )
.arg( .arg(
Arg::with_name("search") Arg::with_name("search")
.short("x") .short('x')
.long("search-string") .long("search-string")
.help("Search for string") .help("Search for string")
.value_name("STRING"), .value_name("STRING"),
) )
.arg( .arg(
Arg::with_name("limit") Arg::with_name("limit")
.short("l") .short('l')
.long("limit") .long("limit")
.help("Print MAX entries") .help("Print MAX entries")
.value_name("MAX") .value_name("MAX")
@ -105,13 +104,13 @@ fn main() -> Result<(), Error> {
) )
.arg( .arg(
Arg::with_name("exclude_greylist") Arg::with_name("exclude_greylist")
.short("g") .short('g')
.long("exclude-greylist") .long("exclude-greylist")
.help("Exclude greylist entries"), .help("Exclude greylist entries"),
) )
.arg( .arg(
Arg::with_name("exclude_ndr") Arg::with_name("exclude_ndr")
.short("n") .short('n')
.long("exclude-ndr") .long("exclude-ndr")
.help("Exclude NDR entries"), .help("Exclude NDR entries"),
) )
@ -2043,7 +2042,7 @@ impl Parser {
self.options.exclude_greylist = args.is_present("exclude_greylist"); self.options.exclude_greylist = args.is_present("exclude_greylist");
self.options.exclude_ndr = args.is_present("exclude_ndr"); 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") { if let Some(string_match) = args.value_of("search") {
self.options.string_match = string_match.to_string(); self.options.string_match = string_match.to_string();