thin-edge / thin-edge.io

The open edge framework for lightweight IoT devices
https://thin-edge.io
Apache License 2.0
222 stars 55 forks source link

don't include binary name and version when printing help of any of the binaries #2051

Closed reubenmiller closed 1 year ago

reubenmiller commented 1 year ago

Is your refactoring request related to a problem? Please describe.

When printing the help text of a command (e.g. c8y-firmware-plugin --help), the binary name and version is displayed on the first line of the help text.

Having the information within the help text makes parsing the output more complicated for automation purposes (e.g. generating automatic do documents from the command output as the version changes more frequently than the help contents).

Below shows an example of the version information which is printed on the first line.

c8y-firmware-plugin 0.11.0-145-ge59e17be

Here is the full example:

Command

c8y-firmware-plugin --help

Output

c8y-firmware-plugin 0.11.0-145-ge59e17be
Thin-edge device firmware management for Cumulocity

USAGE:
    c8y-firmware-plugin [OPTIONS]

OPTIONS:
        --config-dir <CONFIG_DIR>
            [default: /etc/tedge]

        --debug
            Turn-on the debug log level.

            If off only reports ERROR, WARN, and INFO If on also reports DEBUG and TRACE

    -h, --help
            Print help information

    -i, --init
            Create required directories

    -V, --version
            Print version information

Describe the solution you'd like

In comparison with other tooling, it is more common to just display the version via --version (or something similar), rather than printing it out when using --help.

All of those commands have a dedicated version flag should the user want to know the version of the command they are using.

Note

Describe alternatives you've considered

Additional context

didier-wenzek commented 1 year ago

Mostly a matter to upgrade to clap ="4.10" with some issues with deprecated methods:


error[E0599]: no method named `parse` found for struct `Arg` in the current scope
  --> crates/core/tedge/src/cli/mqtt/cli.rs:37:29
   |
37 |         #[clap(short, long, parse(try_from_str = parse_qos), default_value = "0")]
   |                             ^^^^^ method not found in `Arg`
``
didier-wenzek commented 1 year ago

As a side effect of bumping clap version, --help no longer show the version, and this for all the tedge-xxx executables.

gligorisaev commented 1 year ago

QA has thoroughly checked the feature and here are the results:

Checked for: