1 // Note: this requires the `cargo` feature
2 
3 use clap::{app_from_crate, arg};
4 
main()5 fn main() {
6     let matches = app_from_crate!()
7         .arg(arg!(eff: -f))
8         .arg(arg!(pea: -p <PEAR>).required(false))
9         .arg(
10             arg!(slop: [SLOP]).multiple_occurrences(true).last(true), // Indicates that `slop` is only accessible after `--`.
11         )
12         .get_matches();
13 
14     // This is what will happen with `myprog -f -p=bob -- sloppy slop slop`...
15     println!("-f used: {:?}", matches.is_present("eff")); // -f used: true
16     println!("-p's value: {:?}", matches.value_of("pea")); // -p's value: Some("bob")
17     println!(
18         "'slops' values: {:?}",
19         matches
20             .values_of("slop")
21             .map(|vals| vals.collect::<Vec<_>>())
22             .unwrap_or_default()
23     ); // 'slops' values: Some(["sloppy", "slop", "slop"])
24 
25     // Continued program logic goes here...
26 }
27