aboutsummaryrefslogtreecommitdiff
path: root/clap/examples/22_stop_parsing_with_--.rs
blob: a5ba5b38ff9e1c9427313154a431ce8ff4042918 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
extern crate clap;

use clap::{App, Arg};

/// myprog -f -p=bob -- sloppy slop slop
fn main() {

    let matches = App::new("myprog")
        .arg(Arg::with_name("eff")
            .short("f"))
        .arg(Arg::with_name("pea")
             .short("p")
             .takes_value(true))
        .arg(Arg::with_name("slop")
             .multiple(true)
             .last(true))
        .get_matches();


    println!("-f used: {:?}", matches.is_present("eff"));
    println!("-p's value: {:?}", matches.value_of("pea"));
    println!("'slops' values: {:?}", matches.values_of("slop").map(|vals| vals.collect::<Vec<_>>()));

    // Continued program logic goes here...
}