File tree Expand file tree Collapse file tree 3 files changed +9
-2
lines changed
Expand file tree Collapse file tree 3 files changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -169,7 +169,7 @@ pub enum ArgAction {
169169 /// .action(clap::ArgAction::SetFalse)
170170 /// );
171171 ///
172- /// let matches = cmd.clone().try_get_matches_from(["mycmd", "--flag", "--flag" ]).unwrap();
172+ /// let matches = cmd.clone().try_get_matches_from(["mycmd", "--flag"]).unwrap();
173173 /// assert!(matches.contains_id("flag"));
174174 /// assert_eq!(
175175 /// matches.get_one::<bool>("flag").copied(),
Original file line number Diff line number Diff line change @@ -1240,7 +1240,7 @@ impl<'cmd> Parser<'cmd> {
12401240 raw_vals
12411241 } ;
12421242
1243- if matcher. remove ( & arg. id ) && self . cmd . is_args_override_self ( ) {
1243+ if matcher. remove ( & arg. id ) && ! self . cmd . is_args_override_self ( ) {
12441244 return Err ( ClapError :: argument_conflict (
12451245 self . cmd ,
12461246 arg. to_string ( ) ,
Original file line number Diff line number Diff line change @@ -240,8 +240,15 @@ fn set_false() {
240240 assert_eq ! ( matches. contains_id( "mammal" ) , true ) ;
241241 assert_eq ! ( matches. index_of( "mammal" ) , Some ( 1 ) ) ;
242242
243+ let result = cmd
244+ . clone ( )
245+ . try_get_matches_from ( [ "test" , "--mammal" , "--mammal" ] ) ;
246+ let err = result. err ( ) . unwrap ( ) ;
247+ assert_eq ! ( err. kind( ) , ErrorKind :: ArgumentConflict ) ;
248+
243249 let matches = cmd
244250 . clone ( )
251+ . args_override_self ( true )
245252 . try_get_matches_from ( [ "test" , "--mammal" , "--mammal" ] )
246253 . unwrap ( ) ;
247254 assert_eq ! ( * matches. get_one:: <bool >( "mammal" ) . unwrap( ) , false ) ;
You can’t perform that action at this time.
0 commit comments