From 246f239d9f40f633160f0c18f87a20922d4e77bb Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:06:37 +0200 Subject: Merging debian version 1.65.0+dfsg1-2. Signed-off-by: Daniel Baumann --- vendor/clap/src/builder/action.rs | 8 +-- vendor/clap/src/builder/app_settings.rs | 32 +++++----- vendor/clap/src/builder/arg.rs | 20 ++++++ vendor/clap/src/builder/arg_settings.rs | 27 ++++---- vendor/clap/src/builder/command.rs | 106 ++++++++++++++++++++++++++++---- vendor/clap/src/builder/value_parser.rs | 2 +- 6 files changed, 148 insertions(+), 47 deletions(-) (limited to 'vendor/clap/src/builder') diff --git a/vendor/clap/src/builder/action.rs b/vendor/clap/src/builder/action.rs index ab3314290..71a91a8b1 100644 --- a/vendor/clap/src/builder/action.rs +++ b/vendor/clap/src/builder/action.rs @@ -183,16 +183,16 @@ pub enum ArgAction { /// assert!(matches.contains_id("flag")); /// assert_eq!(matches.occurrences_of("flag"), 0); /// assert_eq!( - /// matches.get_one::("flag").copied(), - /// Some(2) + /// matches.get_count("flag"), + /// 2 /// ); /// /// let matches = cmd.try_get_matches_from(["mycmd"]).unwrap(); /// assert!(matches.contains_id("flag")); /// assert_eq!(matches.occurrences_of("flag"), 0); /// assert_eq!( - /// matches.get_one::("flag").copied(), - /// Some(0) + /// matches.get_count("flag"), + /// 0 /// ); /// ``` Count, diff --git a/vendor/clap/src/builder/app_settings.rs b/vendor/clap/src/builder/app_settings.rs index e2d9ba6b1..88bc243c4 100644 --- a/vendor/clap/src/builder/app_settings.rs +++ b/vendor/clap/src/builder/app_settings.rs @@ -400,23 +400,20 @@ pub enum AppSettings { )] NoAutoVersion, - /// Deprecated, replaced with [`AppSettings::AllowHyphenValues`] + /// Deprecated, replaced with [`Command::allow_hyphen_values`] #[cfg_attr( feature = "deprecated", - deprecated( - since = "3.0.0", - note = "Replaced with `AppSettings::AllowHyphenValues`" - ) + deprecated(since = "3.0.0", note = "Replaced with `Command::allow_hyphen_values`") )] #[doc(hidden)] AllowLeadingHyphen, - /// Deprecated, this is now the default, see [`AppSettings::AllowInvalidUtf8ForExternalSubcommands`] and [`ArgSettings::AllowInvalidUtf8`][crate::ArgSettings::AllowInvalidUtf8] for the opposite. + /// Deprecated, replaced with [`Command::allow_invalid_utf8_for_external_subcommands`] and [`Command::is_allow_invalid_utf8_for_external_subcommands_set`] #[cfg_attr( feature = "deprecated", deprecated( since = "3.0.0", - note = "This is now the default see `AppSettings::AllowInvalidUtf8ForExternalSubcommands` and `ArgSettings::AllowInvalidUtf8` for the opposite." + note = "Replaced with `Command::allow_invalid_utf8_for_external_subcommands` and `Command::is_allow_invalid_utf8_for_external_subcommands_set`" ) )] #[doc(hidden)] @@ -462,42 +459,47 @@ pub enum AppSettings { #[doc(hidden)] ColorNever, - /// Deprecated, replaced with [`AppSettings::DisableHelpFlag`] + /// Deprecated, replaced with [`Command::disable_help_flag`] and [`Command::is_disable_help_flag_set`] #[cfg_attr( feature = "deprecated", - deprecated(since = "3.0.0", note = "Replaced with `AppSettings::DisableHelpFlag`") + deprecated( + since = "3.0.0", + note = "Replaced with `Command::disable_help_flag` and `Command::is_disable_help_flag_set`" + ) )] #[doc(hidden)] DisableHelpFlags, - /// Deprecated, replaced with [`AppSettings::DisableVersionFlag`] + /// Deprecated, replaced with [`Command::disable_version_flag`] and + /// [`Command::is_disable_version_flag_set`] #[cfg_attr( feature = "deprecated", deprecated( since = "3.0.0", - note = "Replaced with `AppSettings::DisableVersionFlag`" + note = "Replaced with `Command::disable_version_flag` and `Command::is_disable_version_flag_set`" ) )] #[doc(hidden)] DisableVersion, - /// Deprecated, replaced with [`AppSettings::PropagateVersion`] + /// Deprecated, replaced with [`Command::propagate_version`] and [`Command::is_propagate_version_set`] #[cfg_attr( feature = "deprecated", deprecated( since = "3.0.0", - note = "Replaced with `AppSettings::PropagateVersion`" + note = "Replaced with `Command::propagate_version` and `Command::is_propagate_version_set`" ) )] #[doc(hidden)] GlobalVersion, - /// Deprecated, replaced with [`AppSettings::HidePossibleValues`] + /// Deprecated, replaced with [`Command::hide_possible_values`] and + /// [`Arg::is_hide_possible_values_set`] #[cfg_attr( feature = "deprecated", deprecated( since = "3.0.0", - note = "Replaced with AppSettings::HidePossibleValues" + note = "Replaced with `Command::hide_possible_values` and `Arg::is_hide_possible_values_set`" ) )] #[doc(hidden)] diff --git a/vendor/clap/src/builder/arg.rs b/vendor/clap/src/builder/arg.rs index 63e88e80e..e9403d0b7 100644 --- a/vendor/clap/src/builder/arg.rs +++ b/vendor/clap/src/builder/arg.rs @@ -4316,6 +4316,16 @@ impl<'help> Arg<'help> { } } + /// Get *all* short aliases for this argument, if any, both visible and hidden. + #[inline] + pub fn get_all_short_aliases(&self) -> Option> { + if self.short_aliases.is_empty() { + None + } else { + Some(self.short_aliases.iter().map(|(s, _)| s).copied().collect()) + } + } + /// Get the short option name and its visible aliases, if any #[inline] pub fn get_short_and_visible_aliases(&self) -> Option> { @@ -4351,6 +4361,16 @@ impl<'help> Arg<'help> { } } + /// Get *all* aliases for this argument, if any, both visible and hidden. + #[inline] + pub fn get_all_aliases(&self) -> Option> { + if self.aliases.is_empty() { + None + } else { + Some(self.aliases.iter().map(|(s, _)| s).copied().collect()) + } + } + /// Get the long option name and its visible aliases, if any #[inline] pub fn get_long_and_visible_aliases(&self) -> Option> { diff --git a/vendor/clap/src/builder/arg_settings.rs b/vendor/clap/src/builder/arg_settings.rs index 3b7faf7bf..ecc064caa 100644 --- a/vendor/clap/src/builder/arg_settings.rs +++ b/vendor/clap/src/builder/arg_settings.rs @@ -50,14 +50,10 @@ pub enum ArgSettings { ) )] MultipleValues, - /// Deprecated, replaced with [`Arg::multiple_occurrences`] and - /// [`Arg::is_multiple_occurrences_set`] + /// Deprecated, replaced with [`Arg::action`] ([Issue #3772](https://github.com/clap-rs/clap/issues/3772)) #[cfg_attr( feature = "deprecated", - deprecated( - since = "3.1.0", - note = "Replaced with `Arg::multiple_occurrences` and `Arg::is_multiple_occurrences_set`" - ) + deprecated(since = "3.1.0", note = "Replaced with `Arg::action` (Issue #3772)") )] MultipleOccurrences, /// Deprecated, see [`ArgSettings::MultipleOccurrences`] (most likely what you want) and @@ -66,18 +62,17 @@ pub enum ArgSettings { feature = "deprecated", deprecated( since = "3.0.0", - note = "Split into `ArgSettings::MultipleOccurrences` (most likely what you want) and `ArgSettings::MultipleValues`" + note = "Split into `Arg::multiple_occurrences` (most likely what you want) and `Arg::multiple_values`" ) )] #[doc(hidden)] Multiple, - /// Deprecated, replaced with [`Arg::forbid_empty_values`] and - /// [`Arg::is_forbid_empty_values_set`] + /// Deprecated, replaced with [`Arg::value_parser(NonEmptyStringValueParser::new())`] #[cfg_attr( feature = "deprecated", deprecated( since = "3.1.0", - note = "Replaced with `Arg::forbid_empty_values` and `Arg::is_forbid_empty_values_set`" + note = "Replaced with `Arg::value_parser(NonEmptyStringValueParser::new())`" ) )] ForbidEmptyValues, @@ -157,12 +152,13 @@ pub enum ArgSettings { ) )] AllowHyphenValues, - /// Deprecated, replaced with [`ArgSettings::AllowHyphenValues`] + /// Deprecated, replaced with [`Arg::allow_hyphen_values`] and + /// [`Arg::is_allow_hyphen_values_set`] #[cfg_attr( feature = "deprecated", deprecated( since = "3.0.0", - note = "Replaced with `ArgSettings::AllowHyphenValues`" + note = "Replaced with `Arg::allow_hyphen_values` and `Arg::is_allow_hyphen_values_set`" ) )] #[doc(hidden)] @@ -203,10 +199,13 @@ pub enum ArgSettings { ) )] IgnoreCase, - /// Deprecated, replaced with [`ArgSettings::IgnoreCase`] + /// Deprecated, replaced with [`Arg::ignore_case`] and [`Arg::is_ignore_case_set`] #[cfg_attr( feature = "deprecated", - deprecated(since = "3.0.0", note = "Replaced with `ArgSettings::IgnoreCase`") + deprecated( + since = "3.0.0", + note = "Replaced with `Arg::ignore_case` and `Arg::is_ignore_case_set`" + ) )] #[doc(hidden)] CaseInsensitive, diff --git a/vendor/clap/src/builder/command.rs b/vendor/clap/src/builder/command.rs index 1fcb64ecc..de59ad8cd 100644 --- a/vendor/clap/src/builder/command.rs +++ b/vendor/clap/src/builder/command.rs @@ -274,6 +274,50 @@ impl<'help> App<'help> { self } + /// Allows one to mutate a [`Command`] after it's been added as a subcommand. + /// + /// This can be useful for modifying auto-generated arguments of nested subcommands with + /// [`Command::mut_arg`]. + /// + /// # Examples + /// + /// ```rust + /// # use clap::Command; + /// + /// let mut cmd = Command::new("foo") + /// .subcommand(Command::new("bar")) + /// .mut_subcommand("bar", |subcmd| subcmd.disable_help_flag(true)); + /// + /// let res = cmd.try_get_matches_from_mut(vec!["foo", "bar", "--help"]); + /// + /// // Since we disabled the help flag on the "bar" subcommand, this should err. + /// + /// assert!(res.is_err()); + /// + /// let res = cmd.try_get_matches_from_mut(vec!["foo", "bar"]); + /// assert!(res.is_ok()); + /// ``` + #[must_use] + pub fn mut_subcommand<'a, T, F>(mut self, subcmd_id: T, f: F) -> Self + where + F: FnOnce(App<'help>) -> App<'help>, + T: Into<&'a str>, + { + let subcmd_id: &str = subcmd_id.into(); + let id = Id::from(subcmd_id); + + let pos = self.subcommands.iter().position(|s| s.id == id); + + let subcmd = if let Some(idx) = pos { + self.subcommands.remove(idx) + } else { + App::new(subcmd_id) + }; + + self.subcommands.push(f(subcmd)); + self + } + /// Adds an [`ArgGroup`] to the application. /// /// [`ArgGroup`]s are a family of related arguments. @@ -700,7 +744,7 @@ impl<'help> App<'help> { /// [`io::stdout()`]: std::io::stdout() pub fn print_help(&mut self) -> io::Result<()> { self._build_self(); - let color = self.get_color(); + let color = self.color_help(); let mut c = Colorizer::new(Stream::Stdout, color); let usage = Usage::new(self); @@ -725,7 +769,7 @@ impl<'help> App<'help> { /// [`--help` (long)]: Arg::long_help() pub fn print_long_help(&mut self) -> io::Result<()> { self._build_self(); - let color = self.get_color(); + let color = self.color_help(); let mut c = Colorizer::new(Stream::Stdout, color); let usage = Usage::new(self); @@ -1604,6 +1648,14 @@ impl<'help> App<'help> { /// strings. After this setting is set, this will be *the only* usage string /// displayed to the user! /// + /// **NOTE:** Multiple usage lines may be present in the usage argument, but + /// some rules need to be followed to ensure the usage lines are formatted + /// correctly by the default help formatter: + /// + /// - Do not indent the first usage line. + /// - Indent all subsequent usage lines with four spaces. + /// - The last line must not end with a newline. + /// /// # Examples /// /// ```no_run @@ -1612,6 +1664,20 @@ impl<'help> App<'help> { /// .override_usage("myapp [-clDas] ") /// # ; /// ``` + /// + /// Or for multiple usage lines: + /// + /// ```no_run + /// # use clap::{Command, Arg}; + /// Command::new("myprog") + /// .override_usage( + /// "myapp -X [-a] [-b] \n \ + /// myapp -Y [-c] \n \ + /// myapp -Z [-d|-e]" + /// ) + /// # ; + /// ``` + /// /// [`ArgMatches::usage`]: ArgMatches::usage() #[must_use] pub fn override_usage>(mut self, usage: S) -> Self { @@ -3512,15 +3578,21 @@ impl<'help> App<'help> { if arg.is_global_set() { self.get_global_arg_conflicts_with(arg) } else { - arg.blacklist - .iter() - .map(|id| { - self.args.args().find(|arg| arg.id == *id).expect( - "Command::get_arg_conflicts_with: \ - The passed arg conflicts with an arg unknown to the cmd", - ) - }) - .collect() + let mut result = Vec::new(); + for id in arg.blacklist.iter() { + if let Some(arg) = self.find(id) { + result.push(arg); + } else if let Some(group) = self.find_group(id) { + result.extend( + self.unroll_args_in_group(&group.id) + .iter() + .map(|id| self.find(id).expect(INTERNAL_ERROR_MSG)), + ); + } else { + panic!("Command::get_arg_conflicts_with: The passed arg conflicts with an arg unknown to the cmd"); + } + } + result } } @@ -4264,7 +4336,8 @@ impl<'help> App<'help> { use std::fmt::Write; let mut mid_string = String::from(" "); - if !self.is_subcommand_negates_reqs_set() { + if !self.is_subcommand_negates_reqs_set() && !self.is_args_conflicts_with_subcommands_set() + { let reqs = Usage::new(self).get_required_usage_from(&[], None, true); // maybe Some(m) for s in &reqs { @@ -4347,7 +4420,9 @@ impl<'help> App<'help> { if !self.is_set(AppSettings::BinNameBuilt) { let mut mid_string = String::from(" "); - if !self.is_subcommand_negates_reqs_set() { + if !self.is_subcommand_negates_reqs_set() + && !self.is_args_conflicts_with_subcommands_set() + { let reqs = Usage::new(self).get_required_usage_from(&[], None, true); // maybe Some(m) for s in &reqs { @@ -5107,3 +5182,8 @@ where _ => None, } } + +#[test] +fn check_auto_traits() { + static_assertions::assert_impl_all!(Command: Send, Sync, Unpin); +} diff --git a/vendor/clap/src/builder/value_parser.rs b/vendor/clap/src/builder/value_parser.rs index 397537c9f..0492f2782 100644 --- a/vendor/clap/src/builder/value_parser.rs +++ b/vendor/clap/src/builder/value_parser.rs @@ -12,7 +12,7 @@ use crate::parser::AnyValueId; /// use within an application. /// /// See -/// - [`value_parser!`] for automatically selecting an implementation for a given type +/// - [`value_parser!`][crate::value_parser] for automatically selecting an implementation for a given type /// - [`ValueParser::new`] for additional [`TypedValueParser`] that can be used /// /// # Example -- cgit v1.2.3