mirror of
https://github.com/clap-rs/clap
synced 2024-12-13 22:32:33 +00:00
Rename setting DisableVersion => DisableVersionFlag
This commit is contained in:
parent
45f0ee8b55
commit
d6e2246aab
9 changed files with 20 additions and 19 deletions
|
@ -12,6 +12,7 @@ TODO: `cargo`, `std` features
|
|||
|
||||
* **Renamed Settings**
|
||||
* `AppSettings::DisableHelpFlags` => `AppSettings::DisableHelpFlag`
|
||||
* `AppSettings::DisableVersion` => `AppSettings::DisableVersionFlag`
|
||||
|
||||
#### Features
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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(&[
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -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")
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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::<AppSettings>().unwrap(),
|
||||
AppSettings::DisableVersion
|
||||
"disableversionflag".parse::<AppSettings>().unwrap(),
|
||||
AppSettings::DisableVersionFlag
|
||||
);
|
||||
assert_eq!(
|
||||
"dontcollapseargsinusage".parse::<AppSettings>().unwrap(),
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
|
|
|
@ -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 = {
|
||||
|
|
Loading…
Reference in a new issue