summaryrefslogtreecommitdiffstats
path: root/vendor/clap_builder/src/parser/parser.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 03:59:24 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 03:59:24 +0000
commit023939b627b7dc93b01471f7d41fb8553ddb4ffa (patch)
tree60fc59477c605c72b0a1051409062ddecc43f877 /vendor/clap_builder/src/parser/parser.rs
parentAdding debian version 1.72.1+dfsg1-1. (diff)
downloadrustc-023939b627b7dc93b01471f7d41fb8553ddb4ffa.tar.xz
rustc-023939b627b7dc93b01471f7d41fb8553ddb4ffa.zip
Merging upstream version 1.73.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/clap_builder/src/parser/parser.rs')
-rw-r--r--vendor/clap_builder/src/parser/parser.rs27
1 files changed, 23 insertions, 4 deletions
diff --git a/vendor/clap_builder/src/parser/parser.rs b/vendor/clap_builder/src/parser/parser.rs
index d2e198b28..d6d8e8da4 100644
--- a/vendor/clap_builder/src/parser/parser.rs
+++ b/vendor/clap_builder/src/parser/parser.rs
@@ -302,6 +302,13 @@ impl<'cmd> Parser<'cmd> {
.map(|p_name| !p_name.is_last_set())
.unwrap_or_default();
+ let is_terminated = self
+ .cmd
+ .get_keymap()
+ .get(&pos_counter)
+ .map(|a| a.get_value_terminator().is_some())
+ .unwrap_or_default();
+
let missing_pos = self.cmd.is_allow_missing_positional_set()
&& is_second_to_last
&& !trailing_values;
@@ -309,7 +316,7 @@ impl<'cmd> Parser<'cmd> {
debug!("Parser::get_matches_with: Positional counter...{pos_counter}");
debug!("Parser::get_matches_with: Low index multiples...{low_index_mults:?}");
- if low_index_mults || missing_pos {
+ if (low_index_mults || missing_pos) && !is_terminated {
let skip_current = if let Some(n) = raw_args.peek(&args_cursor) {
if let Some(arg) = self
.cmd
@@ -474,6 +481,10 @@ impl<'cmd> Parser<'cmd> {
}
}
+ let suggested_trailing_arg = !trailing_values
+ && self.cmd.has_positionals()
+ && (arg_os.is_long() || arg_os.is_short());
+
if !(self.cmd.is_args_conflicts_with_subcommands_set() && valid_arg_found) {
let candidates = suggestions::did_you_mean(
&arg_os.display().to_string(),
@@ -489,6 +500,7 @@ impl<'cmd> Parser<'cmd> {
.get_bin_name()
.unwrap_or_else(|| self.cmd.get_name())
.to_owned(),
+ suggested_trailing_arg,
Usage::new(self.cmd).create_usage_with_title(&[]),
);
}
@@ -505,9 +517,6 @@ impl<'cmd> Parser<'cmd> {
}
}
- let suggested_trailing_arg = !trailing_values
- && self.cmd.has_positionals()
- && (arg_os.is_long() || arg_os.is_short());
ClapError::unknown_argument(
self.cmd,
arg_os.display().to_string(),
@@ -1237,6 +1246,16 @@ impl<'cmd> Parser<'cmd> {
debug!("Help: use_long={use_long}");
Err(self.help_err(use_long))
}
+ ArgAction::HelpShort => {
+ let use_long = false;
+ debug!("Help: use_long={use_long}");
+ Err(self.help_err(use_long))
+ }
+ ArgAction::HelpLong => {
+ let use_long = true;
+ debug!("Help: use_long={use_long}");
+ Err(self.help_err(use_long))
+ }
ArgAction::Version => {
let use_long = match ident {
Some(Identifier::Long) => true,