Skip to content

Commit 4824fcc

Browse files
drusellerskbknapp
authored andcommitted
Add slop example
1 parent 77763e1 commit 4824fcc

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

examples/22_stop_parsing_with_--.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
extern crate clap;
2+
3+
use clap::{App, Arg};
4+
5+
/// myprog -f -p=bob -- sloppy slop slop
6+
fn main() {
7+
8+
let matches = App::new("myprog")
9+
.arg(Arg::with_name("eff")
10+
.short("f"))
11+
.arg(Arg::with_name("pea")
12+
.short("p")
13+
.takes_value(true))
14+
.arg(Arg::with_name("slop")
15+
.multiple(true))
16+
.get_matches();
17+
18+
19+
println!("-f used: {:?}", matches.is_present("eff"));
20+
println!("-p's value: {:?}", matches.value_of("pea"));
21+
println!("'slops' values: {:?}", matches.values_of("slop").map(|vals| vals.collect::<Vec<_>>()));
22+
23+
// Continued program logic goes here...
24+
}

0 commit comments

Comments
 (0)