Revert "Fixes group conflicting with arg which has default value"

This reverts commit 8c76556ac4.
This commit is contained in:
Pavan Kumar Sunkara 2021-11-03 18:25:53 +00:00
parent 706085d9c5
commit 736cb28dd0
2 changed files with 1 additions and 20 deletions

View file

@ -282,7 +282,7 @@ impl<'help, 'app, 'parser> Validator<'help, 'app, 'parser> {
.count()
> 1
};
let conf_with_arg = || g.conflicts.iter().any(|x| !matcher.is_default_value(x));
let conf_with_arg = || g.conflicts.iter().any(|x| matcher.contains(x));
let arg_conf_with_gr = || {
matcher
.arg_names()

View file

@ -270,22 +270,3 @@ fn conflicts_with_alongside_default() {
assert_eq!(m.value_of("opt"), Some("default"));
assert!(m.is_present("flag"));
}
#[test]
fn group_conflicts_with_default_arg() {
let result = App::new("conflict")
.arg(Arg::new("opt").long("opt").default_value("default"))
.arg(Arg::new("flag").long("flag").group("one"))
.group(ArgGroup::new("one").conflicts_with("opt"))
.try_get_matches_from(vec!["myprog", "--flag"]);
assert!(
result.is_ok(),
"arg group conflicts_with should ignore default_value: {:?}",
result.unwrap_err()
);
let m = result.unwrap();
assert_eq!(m.value_of("opt"), Some("default"));
assert!(m.is_present("flag"));
}