From d6e2246aab3881126d5ba997352729f1636d590a Mon Sep 17 00:00:00 2001 From: Pavan Kumar Sunkara Date: Sat, 10 Oct 2020 16:53:06 +0200 Subject: [PATCH] Rename setting DisableVersion => DisableVersionFlag --- CHANGELOG.md | 1 + clap_derive/examples/value_hints_derive.rs | 2 +- clap_generate/examples/value_hints.rs | 2 +- clap_generate/src/generators/mod.rs | 6 +++--- clap_generate/tests/value_hints.rs | 2 +- src/build/app/mod.rs | 4 ++-- src/build/app/settings.rs | 16 ++++++++-------- src/build/app/tests.rs | 4 ++-- tests/help.rs | 2 +- 9 files changed, 20 insertions(+), 19 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8efff1b4..4f630fe6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ TODO: `cargo`, `std` features * **Renamed Settings** * `AppSettings::DisableHelpFlags` => `AppSettings::DisableHelpFlag` + * `AppSettings::DisableVersion` => `AppSettings::DisableVersionFlag` #### Features diff --git a/clap_derive/examples/value_hints_derive.rs b/clap_derive/examples/value_hints_derive.rs index 38194115..859411a1 100644 --- a/clap_derive/examples/value_hints_derive.rs +++ b/clap_derive/examples/value_hints_derive.rs @@ -34,7 +34,7 @@ enum GeneratorChoice { name = "value_hints_derive", // AppSettings::TrailingVarArg is required to use ValueHint::CommandWithArguments setting = AppSettings::TrailingVarArg, - setting = AppSettings::DisableVersion + setting = AppSettings::DisableVersionFlag )] struct Opt { /// If provided, outputs the completion file for given shell diff --git a/clap_generate/examples/value_hints.rs b/clap_generate/examples/value_hints.rs index 884a2ffb..91162f10 100644 --- a/clap_generate/examples/value_hints.rs +++ b/clap_generate/examples/value_hints.rs @@ -19,7 +19,7 @@ use std::io; fn build_cli() -> App<'static> { App::new("value_hints") - .setting(AppSettings::DisableVersion) + .setting(AppSettings::DisableVersionFlag) // AppSettings::TrailingVarArg is required to use ValueHint::CommandWithArguments .setting(AppSettings::TrailingVarArg) .arg(Arg::new("generator").long("generate").possible_values(&[ diff --git a/clap_generate/src/generators/mod.rs b/clap_generate/src/generators/mod.rs index 102aeb68..7c1701b1 100644 --- a/clap_generate/src/generators/mod.rs +++ b/clap_generate/src/generators/mod.rs @@ -144,7 +144,7 @@ pub trait Generator { shorts_and_visible_aliases.push('h'); } - if !p.is_set(AppSettings::DisableVersion) + if !p.is_set(AppSettings::DisableVersionFlag) && !shorts_and_visible_aliases.iter().any(|&x| x == 'V') { shorts_and_visible_aliases.push('V'); @@ -173,7 +173,7 @@ pub trait Generator { longs.push(String::from("help")); } - if !p.is_set(AppSettings::DisableVersion) && !longs.iter().any(|x| *x == "version") { + if !p.is_set(AppSettings::DisableVersionFlag) && !longs.iter().any(|x| *x == "version") { longs.push(String::from("version")); } @@ -196,7 +196,7 @@ pub trait Generator { ); } - if !p.is_set(AppSettings::DisableVersion) + if !p.is_set(AppSettings::DisableVersionFlag) && !flags.iter().any(|x| x.get_name() == "version") { flags.push( diff --git a/clap_generate/tests/value_hints.rs b/clap_generate/tests/value_hints.rs index 83d55f30..f050646e 100644 --- a/clap_generate/tests/value_hints.rs +++ b/clap_generate/tests/value_hints.rs @@ -6,7 +6,7 @@ mod completions; pub fn build_app_with_value_hints() -> App<'static> { App::new("my_app") - .setting(AppSettings::DisableVersion) + .setting(AppSettings::DisableVersionFlag) .setting(AppSettings::TrailingVarArg) .arg( Arg::new("choice") diff --git a/src/build/app/mod.rs b/src/build/app/mod.rs index c6332ca7..e0f9a7be 100644 --- a/src/build/app/mod.rs +++ b/src/build/app/mod.rs @@ -2297,7 +2297,7 @@ impl<'help> App<'help> { let gv = $_self.settings.is_set(AppSettings::GlobalVersion); if vsc { - $sc.set(AppSettings::DisableVersion); + $sc.set(AppSettings::DisableVersionFlag); } if gv && $sc.version.is_none() && $_self.version.is_some() { $sc.set(AppSettings::GlobalVersion); @@ -2377,7 +2377,7 @@ impl<'help> App<'help> { .args .iter() .any(|x| x.long == Some("version") || x.id == Id::version_hash()) - || self.is_set(AppSettings::DisableVersion) + || self.is_set(AppSettings::DisableVersionFlag) || self .subcommands .iter() diff --git a/src/build/app/settings.rs b/src/build/app/settings.rs index 5b6bdbcd..19f06e8d 100644 --- a/src/build/app/settings.rs +++ b/src/build/app/settings.rs @@ -16,7 +16,7 @@ bitflags! { const SC_REQUIRED_ELSE_HELP = 1 << 7; const NO_AUTO_HELP = 1 << 8; const NO_AUTO_VERSION = 1 << 9; - const DISABLE_VERSION = 1 << 10; + const DISABLE_VERSION_FLAG = 1 << 10; const HIDDEN = 1 << 11; const TRAILING_VARARG = 1 << 12; const NO_BIN_NAME = 1 << 13; @@ -103,8 +103,8 @@ impl_settings! { AppSettings, AppFlags, => Flags::DISABLE_HELP_SC, DisableHelpFlag("disablehelpflag") => Flags::DISABLE_HELP_FLAG, - DisableVersion("disableversion") - => Flags::DISABLE_VERSION, + DisableVersionFlag("disableversionflag") + => Flags::DISABLE_VERSION_FLAG, GlobalVersion("globalversion") => Flags::GLOBAL_VERSION, HidePossibleValuesInHelp("hidepossiblevaluesinhelp") @@ -666,7 +666,7 @@ pub enum AppSettings { /// # use clap::{App, AppSettings, ErrorKind}; /// let res = App::new("myprog") /// .version("v1.1") - /// .setting(AppSettings::DisableVersion) + /// .setting(AppSettings::DisableVersionFlag) /// .try_get_matches_from(vec![ /// "myprog", "-V" /// ]); @@ -678,7 +678,7 @@ pub enum AppSettings { /// # use clap::{App, AppSettings, ErrorKind}; /// let res = App::new("myprog") /// .version("v1.1") - /// .setting(AppSettings::DisableVersion) + /// .setting(AppSettings::DisableVersionFlag) /// .subcommand(App::new("test")) /// .try_get_matches_from(vec![ /// "myprog", "test", "-V" @@ -688,7 +688,7 @@ pub enum AppSettings { /// ``` /// [``]: ./struct..html /// [`App`]: ./struct.App.html - DisableVersion, + DisableVersionFlag, /// Displays the arguments and [``]s in the help message in the order that they were /// declared in, and not alphabetically which is the default. @@ -1130,8 +1130,8 @@ mod test { AppSettings::DisableHelpSubcommand ); assert_eq!( - "disableversion".parse::().unwrap(), - AppSettings::DisableVersion + "disableversionflag".parse::().unwrap(), + AppSettings::DisableVersionFlag ); assert_eq!( "dontcollapseargsinusage".parse::().unwrap(), diff --git a/src/build/app/tests.rs b/src/build/app/tests.rs index 2f9aaa25..388570c5 100644 --- a/src/build/app/tests.rs +++ b/src/build/app/tests.rs @@ -55,9 +55,9 @@ fn app_send_sync() { #[test] fn issue_2090() { let mut app = App::new("app") - .global_setting(AppSettings::DisableVersion) + .global_setting(AppSettings::DisableVersionFlag) .subcommand(App::new("sub")); app._build(); - assert!(app.subcommands[0].is_set(AppSettings::DisableVersion)); + assert!(app.subcommands[0].is_set(AppSettings::DisableVersionFlag)); } diff --git a/tests/help.rs b/tests/help.rs index d100817a..68475aa0 100644 --- a/tests/help.rs +++ b/tests/help.rs @@ -1920,7 +1920,7 @@ fn after_help_no_args() { let mut app = App::new("myapp") .version("1.0") .setting(AppSettings::DisableHelpFlag) - .setting(AppSettings::DisableVersion) + .setting(AppSettings::DisableVersionFlag) .after_help("This is after help."); let help = {