From 736cb28dd0a2ba971409e76016cbf3a13ef16fe5 Mon Sep 17 00:00:00 2001 From: Pavan Kumar Sunkara Date: Wed, 3 Nov 2021 18:25:53 +0000 Subject: [PATCH] Revert "Fixes group conflicting with arg which has default value" This reverts commit 8c76556ac40f9bf3982e74975078db8ee04bb9e4. --- src/parse/validator.rs | 2 +- tests/conflicts.rs | 19 ------------------- 2 files changed, 1 insertion(+), 20 deletions(-) diff --git a/src/parse/validator.rs b/src/parse/validator.rs index 1b9a59ff..72c5f448 100644 --- a/src/parse/validator.rs +++ b/src/parse/validator.rs @@ -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() diff --git a/tests/conflicts.rs b/tests/conflicts.rs index 128bb6c2..fb866c1c 100644 --- a/tests/conflicts.rs +++ b/tests/conflicts.rs @@ -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")); -}