fix(assert): Call out the action in positional assert

Brought up in #5135
This commit is contained in:
Ed Page 2023-09-25 10:18:37 -05:00
parent cb2d2bcf07
commit 221177b9cb
2 changed files with 3 additions and 2 deletions

View file

@ -746,8 +746,9 @@ fn assert_arg(arg: &Arg) {
);
assert!(
arg.is_takes_value_set(),
"Argument '{}` is positional, it must take a value{}",
"Argument '{}` is positional and it must take a value but action is {:?}{}",
arg.get_id(),
arg.get_action(),
if arg.get_id() == Id::HELP {
" (`mut_arg` no longer works with implicit `--help`)"
} else if arg.get_id() == Id::VERSION {

View file

@ -1730,7 +1730,7 @@ fn issue_2229() {
}
#[test]
#[should_panic = "Argument 'pos` is positional, it must take a value"]
#[should_panic = "Argument 'pos` is positional and it must take a value but action is SetTrue"]
fn disallow_positionals_without_values() {
let cmd = Command::new("test").arg(Arg::new("pos").num_args(0));
cmd.debug_assert();