From 27771ceeb7fd1d1bcff6357e3242db8510d3b534 Mon Sep 17 00:00:00 2001 From: tomjw64 Date: Sun, 16 Aug 2020 03:47:19 -0500 Subject: [PATCH] Show arguments in conflict message in reverse order of input --- src/parse/validator.rs | 4 ++-- tests/conflicts.rs | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/parse/validator.rs b/src/parse/validator.rs index 3517fa02..254c4078 100644 --- a/src/parse/validator.rs +++ b/src/parse/validator.rs @@ -211,8 +211,8 @@ impl<'help, 'app, 'parser> Validator<'help, 'app, 'parser> { }; let usg = self.build_conflict_err_usage(matcher, former_arg, latter); return Err(Error::argument_conflict( - former_arg, - Some(latter_arg.to_string()), + latter_arg, + Some(former_arg.to_string()), &*usg, self.p.app.color(), )?); diff --git a/tests/conflicts.rs b/tests/conflicts.rs index 5eca6e7d..ef3a4b44 100644 --- a/tests/conflicts.rs +++ b/tests/conflicts.rs @@ -2,21 +2,21 @@ mod utils; use clap::{App, Arg, ArgGroup, ErrorKind}; -static CONFLICT_ERR: &str = "error: The argument '--flag' cannot be used with '-F' +static CONFLICT_ERR: &str = "error: The argument '-F' cannot be used with '--flag' USAGE: clap-test --flag --long-option-2 For more information try --help"; -static CONFLICT_ERR_REV: &str = "error: The argument '-F' cannot be used with '--flag' +static CONFLICT_ERR_REV: &str = "error: The argument '--flag' cannot be used with '-F' USAGE: clap-test -F --long-option-2 For more information try --help"; -static CONFLICT_ERR_THREE: &str = "error: The argument '--one' cannot be used with '--two' +static CONFLICT_ERR_THREE: &str = "error: The argument '--two' cannot be used with '--one' USAGE: three_conflicting_arguments --one @@ -190,7 +190,7 @@ fn two_conflicting_arguments() { let a = a.unwrap_err(); assert_eq!( a.cause, - "The argument \'--develop\' cannot be used with \'--production\'" + "The argument \'--production\' cannot be used with \'--develop\'" ); } @@ -218,7 +218,7 @@ fn three_conflicting_arguments() { let a = a.unwrap_err(); assert_eq!( a.cause, - "The argument \'--one\' cannot be used with \'--two\'" + "The argument \'--two\' cannot be used with \'--one\'" ); }