debian/missing-sources/clap/examples/tutorial_builder/03_02_option_mult.rs
raw| 1 | use clap::{command, Arg, ArgAction}; |
| 2 | |
| 3 | fn main() { |
| 4 | let matches = command!() // requires `cargo` feature |
| 5 | .arg( |
| 6 | Arg::new("name") |
| 7 | .short('n') |
| 8 | .long("name") |
| 9 | .action(ArgAction::Append), |
| 10 | ) |
| 11 | .get_matches(); |
| 12 | |
| 13 | let args = matches |
| 14 | .get_many::<String>("name") |
| 15 | .unwrap_or_default() |
| 16 | .map(|v| v.as_str()) |
| 17 | .collect::<Vec<_>>(); |
| 18 | |
| 19 | println!("names: {:?}", &args); |
| 20 | } |