From e34f84b91f1c6341a0015b7bd9a905f9790d1880 Mon Sep 17 00:00:00 2001 From: Dominik Csapak Date: Wed, 25 Oct 2023 13:20:26 +0200 Subject: [PATCH] use pico-args instead of clap Instead of upgrading from clap3 to clap4 (which seems to change their interface every year or so), switch to the much smaller pico-args. (Same as we did for termproxy recently, see [0]) It has almost all features we need (except producing help output) and supports OsString, but wihout any dependencies. This decreases compile time and reduces the size of the resulting binary. It also reduces the lines of code. The only difference is now the different output for errors, e.g. for missing values of options. Help output is copied from the old clap output. 0: https://git.proxmox.com/?p=pve-xtermjs.git;a=commitdiff;h=24d707d0506b120a085b06b5f2b6000696879a1e Signed-off-by: Dominik Csapak Tested-by: Mira Limbeck Reviewed-by: Mira Limbeck --- Cargo.toml | 2 +- src/main.rs | 223 +++++++++++++++++++--------------------------------- 2 files changed, 83 insertions(+), 142 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 725976f..82a9a4f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,7 +11,7 @@ exclude = [ "build", "debian" ] [dependencies] anyhow = "1" -clap = { version = "3.2.23", features = ["cargo"] } flate2 = "1.0" libc = "0.2" proxmox-time = "1.1" +pico-args = { version = "0.4", features = ["combined-flags"] } diff --git a/src/main.rs b/src/main.rs index e55f17b..e7aeeb4 100644 --- a/src/main.rs +++ b/src/main.rs @@ -13,111 +13,55 @@ use anyhow::{bail, Error}; use flate2::read; use libc::time_t; -use clap::{App, Arg}; - mod time; use time::{Tm, CAL_MTOD}; +fn print_usage() { + let pkg_version = env!("CARGO_PKG_VERSION"); + println!( + "\ +pmg-log-tracker {pkg_version} +Proxmox Mailgateway Log Tracker. Tool to scan mail logs. + +USAGE: + pmg-log-tracker [OPTIONS] + +OPTIONS: + -e, --endtime