mirror of
https://github.com/clap-rs/clap
synced 2025-01-06 09:48:43 +00:00
31b22d1a51
Someone should not reasonably expect a coun flag to go up to billions, millions, or even thousands. 255 should be sufficient for anyone, right? The original type was selected to be consistent with `ArgMatches::occurrences_of` but that is also used for tracking how many values appear which can be large with `xargs`. I'm still conflicted on what the "right type" is an wish we could support any numeric type. When I did a search on github though, every case was for debug/quiet flags and only supported 2-3 occurrences, making a `u8` overkill. This came out of a discussion on #3792
16 lines
355 B
Rust
16 lines
355 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::<u8>("verbose")
|
|
.expect("Count always defaulted")
|
|
);
|
|
}
|