Custom version output with clap
⚓ Rust 📅 2025-05-03 👤 surdeus 👁️ 10I'd like to mimic the behavior of of -h vs --help for -V vs --version, in that I'd like -V to give just application name an version, but --version outputs more information.
I would settle for requiring -v/--verbose for the long version output, rather than activating it via --version.
But I'm unsure how to accomplish any of these.
I think I could accomplish the --verbose variant by simply disabling the default "version" logic:
#[derive(Parser, Debug)]
#[command(disable_version_flag = true)]
struct Args {
...
}
.. and then just add my own option for -V and --version.
But how would one go about implementing the other one -- where -V and --version are basically two different options, but are treated as one (with regards to help texts and such)? Is this something ArgGroups can be used for?
Taking a step back .. are there some other mechanisms in clap that can help me achieve this?
1 post - 1 participant
🏷️ rust_feed