clap/examples/tutorial_builder/03_01_flag_count.rs
Ed Page 86a162d1bb fix(parser): Deprecate occurrences_of
This mostly exist for
- Knowing of the value came from the command-line but we now have
  `ArgMatches::source`
- Counting the number of flags but we now have `ArgAction::Count`
2022-06-07 13:30:32 -05:00

16 lines
356 B
Rust

// Note: this requires the `cargo` feature
use clap::{arg, command, ArgAction};
fn main() {
let matches = command!()
.arg(arg!(-v - -verbose).action(ArgAction::Count))
.get_matches();
println!(
"verbose: {:?}",
matches
.get_one::<u64>("verbose")
.expect("Count always defaulted")
);
}