From dc0db358abe19481e475e10c32149b53370f1a1c Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Thu, 30 May 2024 05:57:31 +0200 Subject: Merging upstream version 1.72.1+dfsg1. Signed-off-by: Daniel Baumann --- vendor/clap_builder/src/builder/debug_asserts.rs | 30 ++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) (limited to 'vendor/clap_builder/src/builder/debug_asserts.rs') diff --git a/vendor/clap_builder/src/builder/debug_asserts.rs b/vendor/clap_builder/src/builder/debug_asserts.rs index 7a7fd6ae1..ef970cdaa 100644 --- a/vendor/clap_builder/src/builder/debug_asserts.rs +++ b/vendor/clap_builder/src/builder/debug_asserts.rs @@ -300,6 +300,28 @@ pub(crate) fn assert_app(cmd: &Command) { arg ); } + + for arg in &group.requires { + // Args listed inside groups should exist + assert!( + cmd.id_exists(arg), + "Command {}: Argument group '{}' requires non-existent '{}' id", + cmd.get_name(), + group.get_id(), + arg + ); + } + + for arg in &group.conflicts { + // Args listed inside groups should exist + assert!( + cmd.id_exists(arg), + "Command {}: Argument group '{}' conflicts with non-existent '{}' id", + cmd.get_name(), + group.get_id(), + arg + ); + } } // Conflicts between flags and subcommands @@ -460,7 +482,7 @@ fn assert_app_flags(cmd: &Command) { )+ if !s.is_empty() { - panic!("{}", s) + panic!("{s}") } } }; @@ -564,9 +586,8 @@ fn _verify_positionals(cmd: &Command) -> bool { || last.is_last_set(); assert!( ok, - "When using a positional argument with `.num_args(1..)` that is *not the \ - last* positional argument, the last positional argument (i.e. the one \ - with the highest index) *must* have .required(true) or .last(true) set." + "Positional argument `{last}` *must* have `required(true)` or `last(true)` set \ + because a prior positional argument (`{second_to_last}`) has `num_args(1..)`" ); // We make sure if the second to last is Multiple the last is ArgSettings::Last @@ -582,6 +603,7 @@ fn _verify_positionals(cmd: &Command) -> bool { .get_positionals() .filter(|p| { p.is_multiple_values_set() + && p.get_value_terminator().is_none() && !p.get_num_args().expect(INTERNAL_ERROR_MSG).is_fixed() }) .count(); -- cgit v1.2.3