diff --git a/src/parse/errors.rs b/src/parse/errors.rs index bcd71178..0e902337 100644 --- a/src/parse/errors.rs +++ b/src/parse/errors.rs @@ -549,35 +549,41 @@ impl Error { pub(crate) fn argument_conflict( app: &App, arg: &Arg, - other: Option, + others: Vec, usage: String, ) -> Self { let mut c = Colorizer::new(true, app.get_color()); let arg = arg.to_string(); start_error(&mut c, "The argument '"); - c.warning(arg.clone()); - c.none("' cannot be used with "); + c.warning(arg); + c.none("' cannot be used with"); - match other { - Some(ref name) => { - c.none("'"); - c.warning(name); - c.none("'"); + let mut info = vec![]; + match others.len() { + 0 => { + c.none(" one or more of the other specified arguments"); } - None => { - c.none("one or more of the other specified arguments"); + 1 => { + let v = &others[0]; + c.none(" '"); + c.warning(v.clone()); + c.none("'"); + info.push(v.clone()); } - }; + _ => { + c.none(":"); + for v in others { + c.none("\n "); + c.warning(v.to_string()); + info.push(v.to_string()); + } + } + } put_usage(&mut c, usage); try_help(app, &mut c); - let mut info = vec![arg]; - if let Some(other) = other { - info.push(other); - } - Self::new( c, ErrorKind::ArgumentConflict, diff --git a/src/parse/validator.rs b/src/parse/validator.rs index ff4c48be..30a09b5f 100644 --- a/src/parse/validator.rs +++ b/src/parse/validator.rs @@ -224,7 +224,7 @@ impl<'help, 'app, 'parser> Validator<'help, 'app, 'parser> { Err(Error::argument_conflict( self.p.app, latter_arg, - Some(former_arg.to_string()), + vec![former_arg.to_string()], usg, )) }) @@ -243,7 +243,7 @@ impl<'help, 'app, 'parser> Validator<'help, 'app, 'parser> { Err(Error::argument_conflict( self.p.app, &self.p.app[first], - c_with, + c_with.into_iter().collect(), usg, )) } else { @@ -319,7 +319,7 @@ impl<'help, 'app, 'parser> Validator<'help, 'app, 'parser> { Err(Error::argument_conflict( self.p.app, arg, - None, + Vec::new(), Usage::new(self.p).create_usage_with_title(&[]), )) })