public inbox for pmg-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Thomas Lamprecht <t.lamprecht@proxmox.com>
To: Dominik Csapak <d.csapak@proxmox.com>, pmg-devel@lists.proxmox.com
Subject: Re: [pmg-devel] [PATCH log-tracker] use pico-args instead of clap
Date: Wed, 25 Oct 2023 10:50:28 +0200	[thread overview]
Message-ID: <4727d685-2070-4edb-9680-9c04e36fd25f@proxmox.com> (raw)
In-Reply-To: <20231024125521.769887-1-d.csapak@proxmox.com>

Am 24/10/2023 um 14:55 schrieb Dominik Csapak:
> Instead of upgrading from clap3 to clap4 (which seems to change their
> interface every year or so), switch to the much smaller pico-args.

Thanks for this conversion, while clap provides nice result, the churn
and complexity it brings along is currently simply not worth it IMO.

> 
> It has almost all features we need (except producing help output), but

And most important: works with OsString, i.e., the one must-have most
of those CLI argument crates are lacking..

> wihout any dependencies. This increases compile time and reduces the

s/increases/decreases/ I hope ;-)

> 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.

IMO it could be good to reference that this was done for termproxy too
(someone stumbling over this, could find reading the change, or just
background of other conversions helpful, while the chances are low here,
it's just too cheap to not mention that reference here – iow. yes I
had to spent too much time chasing some little crumbs of information
in commit (messages) that I really want any slightly relevant connection
written out explicitly)

https://git.proxmox.com/?p=pve-xtermjs.git;a=commitdiff;h=24d707d0506b120a085b06b5f2b6000696879a1e;hp=749ebb0907293a9f1cf0f5074e0a240f39f94f6f


> 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" ]

> +fn print_usage() {
> +    println!(
> +        "\
> +pmg-log-tracker {}
> +Proxmox Mailgateway Log Tracker. Tool to scan mail logs.
> +
> +USAGE:
> +    pmg-log-tracker [OPTIONS]
> +
> +OPTIONS:
> +    -e, --endtime <TIME>            End time (YYYY-MM-DD HH:MM:SS) or seconds since epoch
> +    -f, --from <SENDER>             Mails from SENDER
> +    -g, --exclude-greylist          Exclude greylist entries
> +    -h, --host <HOST>               Hostname or Server IP
> +        --help                      Print help information
> +    -i, --inputfile <INPUTFILE>     Input file to use instead of /var/log/syslog, or '-' for stdin
> +    -l, --limit <MAX>               Print MAX entries [default: 0]
> +    -m, --message-id <MSGID>        Message ID (exact match)
> +    -n, --exclude-ndr               Exclude NDR entries
> +    -q, --queue-id <QID>            Queue ID (exact match), can be specified multiple times
> +    -s, --starttime <TIME>          Start time (YYYY-MM-DD HH:MM:SS) or seconds since epoch
> +    -t, --to <RECIPIENT>            Mails to RECIPIENT
> +    -v, --verbose                   Verbose output, can be specified multiple times
> +    -V, --version                   Print version information
> +    -x, --search-string <STRING>    Search for string",
> +        env!("CARGO_PKG_VERSION")

nit: I find that a bit hard to read and think that this is one of the rarer
case where a "useless" intermediate variable could be indeed a bit useful.

let pkg_version = env!("CARGO_PKG_VERSION");

print!("... {pkg_version} ...");

and another nit: FWIW, env! is const, so this could be still just a usage
str constant (e.g., using concat!), but not that relevant and in this
relatively big single-file source it might be nicer to have it as function
– so fine by me as is.




      reply	other threads:[~2023-10-25  8:50 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-24 12:55 Dominik Csapak
2023-10-25  8:50 ` Thomas Lamprecht [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4727d685-2070-4edb-9680-9c04e36fd25f@proxmox.com \
    --to=t.lamprecht@proxmox.com \
    --cc=d.csapak@proxmox.com \
    --cc=pmg-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal