]>
Commit | Line | Data |
---|---|---|
1 | // Note: this requires the `cargo` feature | |
2 | ||
3 | use clap::{command, Arg, ArgAction}; | |
4 | ||
5 | fn main() { | |
6 | let matches = command!() | |
7 | .arg( | |
8 | Arg::new("verbose") | |
9 | .short('v') | |
10 | .long("verbose") | |
11 | .action(ArgAction::SetTrue), | |
12 | ) | |
13 | .get_matches(); | |
14 | ||
15 | println!( | |
16 | "verbose: {:?}", | |
17 | *matches | |
18 | .get_one::<bool>("verbose") | |
19 | .expect("defaulted by clap") | |
20 | ); | |
21 | } |