From b0ff215447c2de038882ebbfe8717043936730be Mon Sep 17 00:00:00 2001 From: Ed Page Date: Wed, 18 Aug 2021 10:53:05 -0500 Subject: [PATCH] fix: Ease clap2->clap3 migration with deprecations Fixes #2617 --- src/build/arg/mod.rs | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/build/arg/mod.rs b/src/build/arg/mod.rs index 2608e52d538..62a952f9b09 100644 --- a/src/build/arg/mod.rs +++ b/src/build/arg/mod.rs @@ -311,6 +311,12 @@ impl<'help> Arg<'help> { } } + /// Deprecated, see [`Arg::new`] + #[deprecated(since = "3.0.0", note = "Replaced with `Arg::new`")] + pub fn with_name>(n: S) -> Self { + Self::new(n) + } + pub(crate) fn generated(mut self) -> Self { self.provider = ArgProvider::Generated; self @@ -666,6 +672,12 @@ impl<'help> Arg<'help> { self } + /// Deprecated, see [`Arg::about`] + #[deprecated(since = "3.0.0", note = "Replaced with `Arg::about`")] + pub fn help(self, h: &'help str) -> Self { + self.about(h) + } + /// Sets the long help text of the argument that will be displayed to the user when they print /// the help information with `--help`. Typically this a more detailed (multi-line) message /// that describes the arg. @@ -738,6 +750,12 @@ impl<'help> Arg<'help> { self } + /// Deprecated, see [`Arg::long_about`] + #[deprecated(since = "3.0.0", note = "Replaced with `Arg::long_about`")] + pub fn long_help(self, h: &'help str) -> Self { + self.long_about(h) + } + /// Set this arg as [required] as long as the specified argument is not present at runtime. /// /// **Pro Tip:** Using `Arg::required_unless_present` implies [`Arg::required`] and is therefore not @@ -4352,6 +4370,15 @@ impl<'help> Arg<'help> { } } + /// Deprecated, see [`Arg::multiple_occurrences`] and [`Arg::multiple_values`] + #[deprecated( + since = "3.0.0", + note = "Broken out into `Arg::multiple_occurrences` and `Arg::multiple_values`" + )] + pub fn multiple(self, multi: bool) -> Self { + self.multiple_occurrences(multi).multiple_values(multi) + } + /// Indicates that all parameters passed after this should not be parsed /// individually, but rather passed in their entirety. It is worth noting /// that setting this requires all values to come after a `--` to indicate they