From 28781d677315d1fac3a30cc4c9c2dad976cfed0f Mon Sep 17 00:00:00 2001 From: Ed Page Date: Wed, 8 Jun 2022 12:02:10 -0500 Subject: [PATCH] fix(help): Deprecate NoAutoVersion/NoAutoHelp I'm a bit disappointed we don't have a way to control the action for the help subcommand. Instead, people will need to provide their own and disable ours. Long term, I want to design actions for subcommands but I don't think its worth keeping `NoAutoHelp` around for it. --- src/builder/app_settings.rs | 43 ++++--------------------------------- src/parser/parser.rs | 1 + 2 files changed, 5 insertions(+), 39 deletions(-) diff --git a/src/builder/app_settings.rs b/src/builder/app_settings.rs index d16ffc336df..61b1c18c93e 100644 --- a/src/builder/app_settings.rs +++ b/src/builder/app_settings.rs @@ -293,47 +293,12 @@ pub enum AppSettings { #[deprecated(since = "3.1.0", note = "Replaced with `Command::no_binary_name`")] NoBinaryName, - /// Treat the auto-generated `-h, --help` flags like any other flag, and *not* print the help - /// message. - /// - /// This allows one to handle printing of the help message manually. - /// - /// ```rust - /// # use clap::{Command, AppSettings}; - /// let result = Command::new("myprog") - /// .setting(AppSettings::NoAutoHelp) - /// .try_get_matches_from("myprog --help".split(" ")); - /// - /// // Normally, if `--help` is used clap prints the help message and returns an - /// // ErrorKind::DisplayHelp - /// // - /// // However, `--help` was treated like a normal flag - /// - /// assert!(result.is_ok()); - /// assert!(result.unwrap().is_present("help")); - /// ``` + /// Deprecated, replaced with [`Arg::action`][super::Arg::action] + #[deprecated(since = "3.2.0", note = "Replaced with `Arg::action`")] NoAutoHelp, - /// Treat the auto-generated `-V, --version` flags like any other flag, and - /// *not* print the version message. - /// - /// This allows one to handle printing of the version message manually. - /// - /// ```rust - /// # use clap::{Command, AppSettings}; - /// let result = Command::new("myprog") - /// .version("3.0") - /// .setting(AppSettings::NoAutoVersion) - /// .try_get_matches_from("myprog --version".split(" ")); - /// - /// // Normally, if `--version` is used clap prints the version message and returns an - /// // ErrorKind::DisplayVersion - /// // - /// // However, `--version` was treated like a normal flag - /// - /// assert!(result.is_ok()); - /// assert!(result.unwrap().is_present("version")); - /// ``` + /// Deprecated, replaced with [`Arg::action`][super::Arg::action] + #[deprecated(since = "3.2.0", note = "Replaced with `Arg::action`")] NoAutoVersion, /// Deprecated, replaced with [`AppSettings::AllowHyphenValues`] diff --git a/src/parser/parser.rs b/src/parser/parser.rs index 7b1d5130bf3..b1f365088ad 100644 --- a/src/parser/parser.rs +++ b/src/parser/parser.rs @@ -178,6 +178,7 @@ impl<'help, 'cmd> Parser<'help, 'cmd> { let sc_name = self.possible_subcommand(arg_os.to_value(), valid_arg_found); debug!("Parser::get_matches_with: sc={:?}", sc_name); if let Some(sc_name) = sc_name { + #[allow(deprecated)] if sc_name == "help" && !self.is_set(AS::NoAutoHelp) && !self.cmd.is_disable_help_subcommand_set()