mirror of
https://github.com/clap-rs/clap
synced 2024-12-14 14:52:33 +00:00
Merge #2977
2977: fix(usage)!: Switch positionals... from multi-val to mulit-occur r=pksunkara a=epage Co-authored-by: Ed Page <eopage@gmail.com>
This commit is contained in:
commit
ae48175207
1 changed files with 16 additions and 22 deletions
|
@ -64,12 +64,6 @@ impl<'help> UsageParser<'help> {
|
|||
}
|
||||
}
|
||||
|
||||
if arg.is_positional() && arg.is_set(ArgSettings::MultipleOccurrences) {
|
||||
// We had a positional and need to set mult vals too
|
||||
arg.settings.set(ArgSettings::MultipleValues);
|
||||
arg.settings.unset(ArgSettings::MultipleOccurrences);
|
||||
}
|
||||
|
||||
debug!("UsageParser::parse: vals...{:?}", arg.val_names);
|
||||
arg
|
||||
}
|
||||
|
@ -1109,8 +1103,8 @@ mod test {
|
|||
let a = Arg::from("[pos]... 'some help info'");
|
||||
assert_eq!(a.name, "pos");
|
||||
assert_eq!(a.about.unwrap(), "some help info");
|
||||
assert!(!a.is_set(ArgSettings::MultipleOccurrences));
|
||||
assert!(a.is_set(ArgSettings::MultipleValues));
|
||||
assert!(a.is_set(ArgSettings::MultipleOccurrences));
|
||||
assert!(!a.is_set(ArgSettings::MultipleValues));
|
||||
assert!(!a.is_set(ArgSettings::Required));
|
||||
assert!(a.val_names.is_empty());
|
||||
}
|
||||
|
@ -1120,8 +1114,8 @@ mod test {
|
|||
let a = Arg::from("[pos]... 'some help\' info'");
|
||||
assert_eq!(a.name, "pos");
|
||||
assert_eq!(a.about.unwrap(), "some help' info");
|
||||
assert!(!a.is_set(ArgSettings::MultipleOccurrences));
|
||||
assert!(a.is_set(ArgSettings::MultipleValues));
|
||||
assert!(a.is_set(ArgSettings::MultipleOccurrences));
|
||||
assert!(!a.is_set(ArgSettings::MultipleValues));
|
||||
assert!(!a.is_set(ArgSettings::Required));
|
||||
assert!(a.val_names.is_empty());
|
||||
}
|
||||
|
@ -1131,8 +1125,8 @@ mod test {
|
|||
let a = Arg::from("[pos]... 'some \'help\' info'");
|
||||
assert_eq!(a.name, "pos");
|
||||
assert_eq!(a.about.unwrap(), "some 'help' info");
|
||||
assert!(!a.is_set(ArgSettings::MultipleOccurrences));
|
||||
assert!(a.is_set(ArgSettings::MultipleValues));
|
||||
assert!(a.is_set(ArgSettings::MultipleOccurrences));
|
||||
assert!(!a.is_set(ArgSettings::MultipleValues));
|
||||
assert!(!a.is_set(ArgSettings::Required));
|
||||
assert!(a.val_names.is_empty());
|
||||
}
|
||||
|
@ -1145,8 +1139,8 @@ mod test {
|
|||
);
|
||||
assert_eq!(a.name, "pos");
|
||||
assert_eq!(a.about.unwrap(), "some help\ninfo");
|
||||
assert!(!a.is_set(ArgSettings::MultipleOccurrences));
|
||||
assert!(a.is_set(ArgSettings::MultipleValues));
|
||||
assert!(a.is_set(ArgSettings::MultipleOccurrences));
|
||||
assert!(!a.is_set(ArgSettings::MultipleValues));
|
||||
assert!(!a.is_set(ArgSettings::Required));
|
||||
assert!(a.val_names.is_empty());
|
||||
}
|
||||
|
@ -1159,8 +1153,8 @@ mod test {
|
|||
);
|
||||
assert_eq!(a.name, "pos");
|
||||
assert_eq!(a.about.unwrap(), "some help' stuff\ninfo");
|
||||
assert!(!a.is_set(ArgSettings::MultipleOccurrences));
|
||||
assert!(a.is_set(ArgSettings::MultipleValues));
|
||||
assert!(a.is_set(ArgSettings::MultipleOccurrences));
|
||||
assert!(!a.is_set(ArgSettings::MultipleValues));
|
||||
assert!(!a.is_set(ArgSettings::Required));
|
||||
assert!(a.val_names.is_empty());
|
||||
}
|
||||
|
@ -1170,8 +1164,8 @@ mod test {
|
|||
let a = Arg::from("<pos>... 'some help info'");
|
||||
assert_eq!(a.name, "pos");
|
||||
assert_eq!(a.about.unwrap(), "some help info");
|
||||
assert!(!a.is_set(ArgSettings::MultipleOccurrences));
|
||||
assert!(a.is_set(ArgSettings::MultipleValues));
|
||||
assert!(a.is_set(ArgSettings::MultipleOccurrences));
|
||||
assert!(!a.is_set(ArgSettings::MultipleValues));
|
||||
assert!(a.is_set(ArgSettings::Required));
|
||||
assert!(a.val_names.is_empty());
|
||||
}
|
||||
|
@ -1190,8 +1184,8 @@ mod test {
|
|||
fn pos_mult() {
|
||||
let a = Arg::from("[pos]...");
|
||||
assert_eq!(a.name, "pos");
|
||||
assert!(!a.is_set(ArgSettings::MultipleOccurrences));
|
||||
assert!(a.is_set(ArgSettings::MultipleValues));
|
||||
assert!(a.is_set(ArgSettings::MultipleOccurrences));
|
||||
assert!(!a.is_set(ArgSettings::MultipleValues));
|
||||
assert!(!a.is_set(ArgSettings::Required));
|
||||
assert!(a.val_names.is_empty());
|
||||
}
|
||||
|
@ -1201,8 +1195,8 @@ mod test {
|
|||
let a = Arg::from("<pos>... @a 'some help info'");
|
||||
assert_eq!(a.name, "pos");
|
||||
assert_eq!(a.about.unwrap(), "some help info");
|
||||
assert!(!a.is_set(ArgSettings::MultipleOccurrences));
|
||||
assert!(a.is_set(ArgSettings::MultipleValues));
|
||||
assert!(a.is_set(ArgSettings::MultipleOccurrences));
|
||||
assert!(!a.is_set(ArgSettings::MultipleValues));
|
||||
assert!(a.is_set(ArgSettings::Required));
|
||||
assert!(a.val_names.is_empty());
|
||||
assert_eq!(a.default_vals, vec![std::ffi::OsStr::new("a")]);
|
||||
|
|
Loading…
Reference in a new issue