mirror of
https://github.com/clap-rs/clap
synced 2025-01-10 03:38:50 +00:00
86a162d1bb
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`
16 lines
356 B
Rust
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")
|
|
);
|
|
}
|