Clap: is it possible to have options with multiple values rather than multiple repeats?

I have this in a clap Parser struct:

#[derive(Parser, Debug)]
pub struct Config {
    /// Languages to count [default: all known]
    #[arg(short, long)]
    language: Option<Vec<String>>,
    ...

This means that on the command line for multiple values I must do this:

app -l a -l b -l c file1.dat

But is it possible to do this with clap (which matches Python's argparse's behavior):

app -l a b c -- file1.dat

?

Use #[arg(num_args(0..))]

2 Likes

Thank you, that does exactly what I wanted.

1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.