Skip to content

Commit

Permalink
fix(assert): Call out the action in positional assert
Browse files Browse the repository at this point in the history
Brought up in #5135
  • Loading branch information
epage committed Sep 25, 2023
1 parent cb2d2bc commit 221177b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion clap_builder/src/builder/debug_asserts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion tests/builder/multiple_values.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 221177b

Please sign in to comment.