Skip to content

Commit

Permalink
Merge pull request #5136 from epage/panic
Browse files Browse the repository at this point in the history
fix(assert): Call out the action in positional assert
  • Loading branch information
epage authored Sep 25, 2023
2 parents cb2d2bc + 221177b commit 0d9b14f
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 0d9b14f

Please sign in to comment.