Skip to content

Commit

Permalink
fix(help): Deprecate NoAutoVersion/NoAutoHelp
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
epage committed Jun 8, 2022
1 parent dffd793 commit ec37408
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 39 deletions.
43 changes: 4 additions & 39 deletions src/builder/app_settings.rs
Expand Up @@ -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::acton]
#[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::acton]
#[deprecated(since = "3.2.0", note = "Replaced with `Arg::action`")]
NoAutoVersion,

/// Deprecated, replaced with [`AppSettings::AllowHyphenValues`]
Expand Down
1 change: 1 addition & 0 deletions src/parser/parser.rs
Expand Up @@ -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()
Expand Down

0 comments on commit ec37408

Please sign in to comment.