alilleybrinker / cargo-spdx

Generate an SPDX Software Bill of Materials for Rust crates.
https://crates.io/crates/cargo-spdx
Other
19 stars 2 forks source link

use Args::parse() to get better UX from clap #8

Closed tofay closed 2 years ago

tofay commented 2 years ago

This gives a better responses when users don't specify -h or don't pass in a valid argument combinartion.

E.g before this change, I get an error when running cargo spdx -h:

$ cargo spdx -h
error: cargo-spdx 0.1.0
Generate an SPDX SBOM for a crate

USAGE:
    cargo spdx [OPTIONS]

OPTIONS:
    -f, --format <FORMAT>        The output format to use: 'kv' (default), 'json', 'yaml', 'rdf'
    -F, --force                  Force the output, replacing any existing file with the same name
    -h, --help                   Print help information
    -H, --host-url <HOST_URL>    The URL where the SBOM will be hosted. Must be unique for each SBOM
    -n, --no-interact            Do not run interactively
    -o, --output <OUTPUT>        The path of the desired output file
    -V, --version                Print version information

After:

$ cargo spdx -h
cargo-spdx 0.1.0
Generate an SPDX SBOM for a crate

USAGE:
    cargo spdx [OPTIONS]

OPTIONS:
    -f, --format <FORMAT>        The output format to use: 'kv' (default), 'json', 'yaml', 'rdf'
    -F, --force                  Force the output, replacing any existing file with the same name
    -h, --help                   Print help information
    -H, --host-url <HOST_URL>    The URL where the SBOM will be hosted. Must be unique for each SBOM
    -n, --no-interact            Do not run interactively
    -o, --output <OUTPUT>        The path of the desired output file
    -V, --version                Print version information

Second one has color terminal support too.