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:
bors[bot] 2021-11-03 01:47:44 +00:00 committed by GitHub
commit ae48175207
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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")]);