-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Description
Please complete the following tasks
- I have searched the discussions
- I have searched the open and rejected issues
Clap Version
master
Describe your use case
Command line options with a default_missing_value
can be used as flags and then take on a specified default value. This behavior is quite useful. However, the user discoverability of it seems to be non-existent? As in, based on the help output a user couldn't know whether an option has a default_missing_value
. E.g.:
Usage: clap-6109 [OPTIONS]
Options:
--color [<COLOR>] [default: auto] [possible values: auto, always, never]
-h, --help Print help
-V, --version Print version
Source code
#!/usr/bin/env nargo
---
[dependencies]
clap = { version = "4", features = ["derive"] }
---
use clap::Parser;
#[derive(Parser, Debug)]
#[command(version, about, long_about = None)]
struct Cli {
#[arg(
long,
value_parser = ["auto", "always", "never"],
default_value = "auto",
default_missing_value = "always",
num_args = 0..=1,
)]
color: String,
}
fn main() {
let cli = Cli::parse();
println!("{cli:#?}");
}
Describe the solution you'd like
Add default missing values to the generated help message. If included/displayed the same way as default values, it would look like:
Usage: clap-6109 [OPTIONS]
Options:
--color [<COLOR>] [default: auto] [default missing value: always] [possible values: auto, always, never]
-h, --help Print help
-V, --version Print version
Potentially, this should be behind a flag and not the default behavior to include these. Moreover, I have no preference on the format and welcome discussion about it. It seems sensible enough to adopt the already used format for this, hence the proposal.
Alternatives, if applicable
The only way I see a user discovering this behavior is through the help message
Additional Context
This is my first feature request, please point out any mistakes I made 🥺 .