| 1 | use clap::{command, Arg, ArgAction}; |
|---|---|
| 2 | |
| 3 | fn main() { |
| 4 | let matches = command!() // requires `cargo` feature |
| 5 | .arg(Arg::new("name").action(ArgAction::Append)) |
| 6 | .get_matches(); |
| 7 | |
| 8 | let args = matches |
| 9 | .get_many::<String>("name") |
| 10 | .unwrap_or_default() |
| 11 | .map(|v| v.as_str()) |
| 12 | .collect::<Vec<_>>(); |
| 13 | |
| 14 | println!("names: {:?}", &args); |
| 15 | } |
| 16 |
