@@ -38,10 +38,13 @@ fn flag_conflict_with_all() {
38
38
39
39
#[ test]
40
40
fn exclusive_flag ( ) {
41
- let result = Command :: new ( "flag_conflict" )
41
+ let cmd = Command :: new ( "flag_conflict" )
42
42
. arg ( arg ! ( -f --flag "some flag" ) . exclusive ( true ) )
43
- . arg ( arg ! ( -o --other "some flag" ) )
44
- . try_get_matches_from ( vec ! [ "myprog" , "-o" , "-f" ] ) ;
43
+ . arg ( arg ! ( -o --other "some flag" ) ) ;
44
+ let result = cmd. clone ( ) . try_get_matches_from ( vec ! [ "myprog" , "-f" ] ) ;
45
+ assert ! ( result. is_ok( ) , "{}" , result. unwrap_err( ) ) ;
46
+
47
+ let result = cmd. clone ( ) . try_get_matches_from ( vec ! [ "myprog" , "-o" , "-f" ] ) ;
45
48
assert ! ( result. is_err( ) ) ;
46
49
let err = result. err ( ) . unwrap ( ) ;
47
50
assert_eq ! ( err. kind( ) , ErrorKind :: ArgumentConflict ) ;
@@ -71,6 +74,20 @@ fn not_exclusive_with_defaults() {
71
74
assert ! ( result. is_ok( ) , "{}" , result. unwrap_err( ) ) ;
72
75
}
73
76
77
+ #[ test]
78
+ fn not_exclusive_with_group ( ) {
79
+ let cmd = Command :: new ( "test" )
80
+ . group ( clap:: ArgGroup :: new ( "test" ) . arg ( "foo" ) )
81
+ . arg (
82
+ clap:: Arg :: new ( "foo" )
83
+ . long ( "foo" )
84
+ . exclusive ( true )
85
+ . action ( clap:: ArgAction :: SetTrue ) ,
86
+ ) ;
87
+ let result = cmd. try_get_matches_from ( vec ! [ "test" , "--foo" ] ) ;
88
+ assert ! ( result. is_ok( ) , "{}" , result. unwrap_err( ) ) ;
89
+ }
90
+
74
91
#[ test]
75
92
fn default_doesnt_activate_exclusive ( ) {
76
93
let result = Command :: new ( "flag_conflict" )
0 commit comments