From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 375649113E for ; Tue, 13 Feb 2024 15:56:53 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 2017537D3E for ; Tue, 13 Feb 2024 15:56:53 +0100 (CET) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS for ; Tue, 13 Feb 2024 15:56:51 +0100 (CET) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 5DA3F47CEB for ; Tue, 13 Feb 2024 15:56:51 +0100 (CET) Date: Tue, 13 Feb 2024 15:56:49 +0100 From: Stoiko Ivanov To: Dominik Csapak Cc: pmg-devel@lists.proxmox.com Message-ID: <20240213155649.4c577ddf@rosa.proxmox.com> In-Reply-To: <20231025112026.4109852-1-d.csapak@proxmox.com> References: <20231025112026.4109852-1-d.csapak@proxmox.com> X-Mailer: Claws Mail 4.1.1 (GTK 3.24.38; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.087 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record T_SCC_BODY_TEXT_LINE -0.01 - URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [options.to, options.host, main.rs, proxmox.com] Subject: [pmg-devel] applied: [PATCH log-tracker v2] use pico-args instead of clap X-BeenThere: pmg-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Mail Gateway development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 13 Feb 2024 14:56:53 -0000 Nice one! - Thanks for the patch Applied with Mira's R-b, T-b tags (and gave it a spin earlier as well) On Wed, 25 Oct 2023 13:20:26 +0200 Dominik Csapak wrote: > 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 > --- > changes from v1: > * extracted the pkg_version into a variable for interpolated use > * improved commit message, e.g. by referencing the termproxy commit > > 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