mirror of
https://git.proxmox.com/git/pmg-log-tracker
synced 2025-04-28 13:03:18 +00:00
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:
parent
38ad688ccd
commit
3e6542d819
@ -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"
|
||||
|
6
debian/control
vendored
6
debian/control
vendored
@ -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
|
||||
|
31
src/main.rs
31
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::<u8>("verbose").copied().unwrap_or(0) as _;
|
||||
|
||||
if let Some(string_match) = args.value_of("search") {
|
||||
self.options.string_match = string_match.to_string();
|
||||
|
Loading…
Reference in New Issue
Block a user