Reputation: 1369
Let's show what I mean with an example of a program argument:
-q, --quiet, --silent: Don't show output
I tried to do
#[derive(Parser)]
#[command(version = "0.1.0")]
struct Args {
// ...
#[arg(short, long = ["quiet", "silent"], default_value_t = false)]
quiet: bool,
}
but rust gives me an error because the long
argument takes a string, not an array, but is there a workaround using clap to have multiple possible names for the same argument ?
Upvotes: 2
Views: 163
Reputation: 1369
I need to use the alias
argument to arg
for that (or visible_alias
if I want it to display on the help message)
#[arg(short, long, visible_alias = "silent")]
quiet: bool,
Upvotes: 1