mirror of
https://github.com/clap-rs/clap
synced 2024-11-10 23:04:23 +00:00
fix(matched_arg): Allow for more than 256 occurrences of an argument.
This commit is contained in:
parent
bc091c4a78
commit
3731ddb361
3 changed files with 14 additions and 3 deletions
|
@ -326,7 +326,7 @@ impl<'a> ArgMatches<'a> {
|
|||
/// assert_eq!(m.occurrences_of("debug"), 3);
|
||||
/// assert_eq!(m.occurrences_of("flag"), 1);
|
||||
/// ```
|
||||
pub fn occurrences_of<S: AsRef<str>>(&self, name: S) -> u8 {
|
||||
pub fn occurrences_of<S: AsRef<str>>(&self, name: S) -> u64 {
|
||||
self.args.get(name.as_ref()).map_or(0, |a| a.occurs)
|
||||
}
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ use vec_map::VecMap;
|
|||
#[derive(Debug, Clone)]
|
||||
pub struct MatchedArg {
|
||||
#[doc(hidden)]
|
||||
pub occurs: u8,
|
||||
pub occurs: u64,
|
||||
#[doc(hidden)]
|
||||
pub vals: VecMap<OsString>,
|
||||
}
|
||||
|
|
|
@ -63,3 +63,14 @@ fn multiple_occurrences_of_flags_mixed() {
|
|||
assert!(m.is_present("flag"));
|
||||
assert_eq!(m.occurrences_of("flag"), 1);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn multiple_occurrences_of_flags_large_quantity() {
|
||||
let args : Vec<&str> = vec![""].into_iter().chain(vec!["-m"; 1024].into_iter()).collect();
|
||||
let m = App::new("multiple_occurrences")
|
||||
.arg(Arg::from_usage("-m --multflag 'allowed multiple flag'")
|
||||
.multiple(true))
|
||||
.get_matches_from(args);
|
||||
assert!(m.is_present("multflag"));
|
||||
assert_eq!(m.occurrences_of("multflag"), 1024);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue