I'm using Clap and I'm trying to make it so that a subcommand can take multiple values for the argument. The interface I'm after is:
just use repo [files]
An example:
just use radar/dot-files gitaliases ryan-aliases
The repo
argument here will be the string "radar/dot-files" and the files
argument will be a vector of ["gitaliases", "ryan-aliases"]
.
Here's the code that I'm trying to use:
let matches = App::new("just")
.version("v1.0-beta")
.subcommand(
SubCommand::with_name("use")
.arg(Arg::with_name("repo").required(true))
.arg(
Arg::with_name("files")
.required(true)
.multiple(true)
.number_of_values(1),
),
)
.get_matches();
if let Some(matches) = matches.subcommand_matches("use") {
println!("{:?}", matches.value_of("files").unwrap())
}
This outputs just the first file that I specify, rather than all the files.
How can I make it output all the different files, for an arbitrary number of arguments?