Name duplicate option value #1936
-
I am using struct Opts {
// other fields elided
#[clap(short = "F", long, name = "FROM_URL", validator = is_http_url, env = "SYNC_JACKETT_URL"")]
from: Option<Url>,
#[clap(short = "T", long, name = "TO_URL", validator = is_http_url, env = "SYNC_JACKETT_URL")]
to: Option<Url>,
} I had tried to give I don't quite understand why this is a requirement (in this case). As far as I can tell, the If I put Another place this has come up is with multiple options that take a duration as an argument. For instance, you might have It isn't useful from a docs perspective to name each one of these differently and it is actually less clear to not name them at all so that there is |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
The more I think about this, the more I'm assured that clap uses wrong terminology here. You see, the string you pass to Help/error messages is a different topic. How clap decides what to print in |
Beta Was this translation helpful? Give feedback.
The more I think about this, the more I'm assured that clap uses wrong terminology here. You see, the string you pass to
Arg::new()
constructor (#[clap(name = "...")]
attr) isn't exactly the name of the argument but rather identifier. Due to the way arguments are stored and processed, this identifier MUST be unique at all times. This is basically an invariant that must be upheld. I'm actually writing "clap
book" that will cover this topic.Help/error messages is a different topic. How clap decides what to print in
-F <WHAT??>
? Most of the time, it uses the identifier because this is the most common case: the string you pass intoArg::new
is very likely the fitting name for the value. But …