mirror of
https://github.com/clap-rs/clap
synced 2025-03-03 23:07:15 +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**
|
* **Renamed Settings**
|
||||||
* `AppSettings::DisableHelpFlags` => `AppSettings::DisableHelpFlag`
|
* `AppSettings::DisableHelpFlags` => `AppSettings::DisableHelpFlag`
|
||||||
|
* `AppSettings::DisableVersion` => `AppSettings::DisableVersionFlag`
|
||||||
|
|
||||||
#### Features
|
#### Features
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,7 @@ enum GeneratorChoice {
|
||||||
name = "value_hints_derive",
|
name = "value_hints_derive",
|
||||||
// AppSettings::TrailingVarArg is required to use ValueHint::CommandWithArguments
|
// AppSettings::TrailingVarArg is required to use ValueHint::CommandWithArguments
|
||||||
setting = AppSettings::TrailingVarArg,
|
setting = AppSettings::TrailingVarArg,
|
||||||
setting = AppSettings::DisableVersion
|
setting = AppSettings::DisableVersionFlag
|
||||||
)]
|
)]
|
||||||
struct Opt {
|
struct Opt {
|
||||||
/// If provided, outputs the completion file for given shell
|
/// If provided, outputs the completion file for given shell
|
||||||
|
|
|
@ -19,7 +19,7 @@ use std::io;
|
||||||
|
|
||||||
fn build_cli() -> App<'static> {
|
fn build_cli() -> App<'static> {
|
||||||
App::new("value_hints")
|
App::new("value_hints")
|
||||||
.setting(AppSettings::DisableVersion)
|
.setting(AppSettings::DisableVersionFlag)
|
||||||
// AppSettings::TrailingVarArg is required to use ValueHint::CommandWithArguments
|
// AppSettings::TrailingVarArg is required to use ValueHint::CommandWithArguments
|
||||||
.setting(AppSettings::TrailingVarArg)
|
.setting(AppSettings::TrailingVarArg)
|
||||||
.arg(Arg::new("generator").long("generate").possible_values(&[
|
.arg(Arg::new("generator").long("generate").possible_values(&[
|
||||||
|
|
|
@ -144,7 +144,7 @@ pub trait Generator {
|
||||||
shorts_and_visible_aliases.push('h');
|
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.iter().any(|&x| x == 'V')
|
||||||
{
|
{
|
||||||
shorts_and_visible_aliases.push('V');
|
shorts_and_visible_aliases.push('V');
|
||||||
|
@ -173,7 +173,7 @@ pub trait Generator {
|
||||||
longs.push(String::from("help"));
|
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"));
|
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.iter().any(|x| x.get_name() == "version")
|
||||||
{
|
{
|
||||||
flags.push(
|
flags.push(
|
||||||
|
|
|
@ -6,7 +6,7 @@ mod completions;
|
||||||
|
|
||||||
pub fn build_app_with_value_hints() -> App<'static> {
|
pub fn build_app_with_value_hints() -> App<'static> {
|
||||||
App::new("my_app")
|
App::new("my_app")
|
||||||
.setting(AppSettings::DisableVersion)
|
.setting(AppSettings::DisableVersionFlag)
|
||||||
.setting(AppSettings::TrailingVarArg)
|
.setting(AppSettings::TrailingVarArg)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::new("choice")
|
Arg::new("choice")
|
||||||
|
|
|
@ -2297,7 +2297,7 @@ impl<'help> App<'help> {
|
||||||
let gv = $_self.settings.is_set(AppSettings::GlobalVersion);
|
let gv = $_self.settings.is_set(AppSettings::GlobalVersion);
|
||||||
|
|
||||||
if vsc {
|
if vsc {
|
||||||
$sc.set(AppSettings::DisableVersion);
|
$sc.set(AppSettings::DisableVersionFlag);
|
||||||
}
|
}
|
||||||
if gv && $sc.version.is_none() && $_self.version.is_some() {
|
if gv && $sc.version.is_none() && $_self.version.is_some() {
|
||||||
$sc.set(AppSettings::GlobalVersion);
|
$sc.set(AppSettings::GlobalVersion);
|
||||||
|
@ -2377,7 +2377,7 @@ impl<'help> App<'help> {
|
||||||
.args
|
.args
|
||||||
.iter()
|
.iter()
|
||||||
.any(|x| x.long == Some("version") || x.id == Id::version_hash())
|
.any(|x| x.long == Some("version") || x.id == Id::version_hash())
|
||||||
|| self.is_set(AppSettings::DisableVersion)
|
|| self.is_set(AppSettings::DisableVersionFlag)
|
||||||
|| self
|
|| self
|
||||||
.subcommands
|
.subcommands
|
||||||
.iter()
|
.iter()
|
||||||
|
|
|
@ -16,7 +16,7 @@ bitflags! {
|
||||||
const SC_REQUIRED_ELSE_HELP = 1 << 7;
|
const SC_REQUIRED_ELSE_HELP = 1 << 7;
|
||||||
const NO_AUTO_HELP = 1 << 8;
|
const NO_AUTO_HELP = 1 << 8;
|
||||||
const NO_AUTO_VERSION = 1 << 9;
|
const NO_AUTO_VERSION = 1 << 9;
|
||||||
const DISABLE_VERSION = 1 << 10;
|
const DISABLE_VERSION_FLAG = 1 << 10;
|
||||||
const HIDDEN = 1 << 11;
|
const HIDDEN = 1 << 11;
|
||||||
const TRAILING_VARARG = 1 << 12;
|
const TRAILING_VARARG = 1 << 12;
|
||||||
const NO_BIN_NAME = 1 << 13;
|
const NO_BIN_NAME = 1 << 13;
|
||||||
|
@ -103,8 +103,8 @@ impl_settings! { AppSettings, AppFlags,
|
||||||
=> Flags::DISABLE_HELP_SC,
|
=> Flags::DISABLE_HELP_SC,
|
||||||
DisableHelpFlag("disablehelpflag")
|
DisableHelpFlag("disablehelpflag")
|
||||||
=> Flags::DISABLE_HELP_FLAG,
|
=> Flags::DISABLE_HELP_FLAG,
|
||||||
DisableVersion("disableversion")
|
DisableVersionFlag("disableversionflag")
|
||||||
=> Flags::DISABLE_VERSION,
|
=> Flags::DISABLE_VERSION_FLAG,
|
||||||
GlobalVersion("globalversion")
|
GlobalVersion("globalversion")
|
||||||
=> Flags::GLOBAL_VERSION,
|
=> Flags::GLOBAL_VERSION,
|
||||||
HidePossibleValuesInHelp("hidepossiblevaluesinhelp")
|
HidePossibleValuesInHelp("hidepossiblevaluesinhelp")
|
||||||
|
@ -666,7 +666,7 @@ pub enum AppSettings {
|
||||||
/// # use clap::{App, AppSettings, ErrorKind};
|
/// # use clap::{App, AppSettings, ErrorKind};
|
||||||
/// let res = App::new("myprog")
|
/// let res = App::new("myprog")
|
||||||
/// .version("v1.1")
|
/// .version("v1.1")
|
||||||
/// .setting(AppSettings::DisableVersion)
|
/// .setting(AppSettings::DisableVersionFlag)
|
||||||
/// .try_get_matches_from(vec![
|
/// .try_get_matches_from(vec![
|
||||||
/// "myprog", "-V"
|
/// "myprog", "-V"
|
||||||
/// ]);
|
/// ]);
|
||||||
|
@ -678,7 +678,7 @@ pub enum AppSettings {
|
||||||
/// # use clap::{App, AppSettings, ErrorKind};
|
/// # use clap::{App, AppSettings, ErrorKind};
|
||||||
/// let res = App::new("myprog")
|
/// let res = App::new("myprog")
|
||||||
/// .version("v1.1")
|
/// .version("v1.1")
|
||||||
/// .setting(AppSettings::DisableVersion)
|
/// .setting(AppSettings::DisableVersionFlag)
|
||||||
/// .subcommand(App::new("test"))
|
/// .subcommand(App::new("test"))
|
||||||
/// .try_get_matches_from(vec![
|
/// .try_get_matches_from(vec![
|
||||||
/// "myprog", "test", "-V"
|
/// "myprog", "test", "-V"
|
||||||
|
@ -688,7 +688,7 @@ pub enum AppSettings {
|
||||||
/// ```
|
/// ```
|
||||||
/// [``]: ./struct..html
|
/// [``]: ./struct..html
|
||||||
/// [`App`]: ./struct.App.html
|
/// [`App`]: ./struct.App.html
|
||||||
DisableVersion,
|
DisableVersionFlag,
|
||||||
|
|
||||||
/// Displays the arguments and [``]s in the help message in the order that they were
|
/// Displays the arguments and [``]s in the help message in the order that they were
|
||||||
/// declared in, and not alphabetically which is the default.
|
/// declared in, and not alphabetically which is the default.
|
||||||
|
@ -1130,8 +1130,8 @@ mod test {
|
||||||
AppSettings::DisableHelpSubcommand
|
AppSettings::DisableHelpSubcommand
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
"disableversion".parse::<AppSettings>().unwrap(),
|
"disableversionflag".parse::<AppSettings>().unwrap(),
|
||||||
AppSettings::DisableVersion
|
AppSettings::DisableVersionFlag
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
"dontcollapseargsinusage".parse::<AppSettings>().unwrap(),
|
"dontcollapseargsinusage".parse::<AppSettings>().unwrap(),
|
||||||
|
|
|
@ -55,9 +55,9 @@ fn app_send_sync() {
|
||||||
#[test]
|
#[test]
|
||||||
fn issue_2090() {
|
fn issue_2090() {
|
||||||
let mut app = App::new("app")
|
let mut app = App::new("app")
|
||||||
.global_setting(AppSettings::DisableVersion)
|
.global_setting(AppSettings::DisableVersionFlag)
|
||||||
.subcommand(App::new("sub"));
|
.subcommand(App::new("sub"));
|
||||||
app._build();
|
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")
|
let mut app = App::new("myapp")
|
||||||
.version("1.0")
|
.version("1.0")
|
||||||
.setting(AppSettings::DisableHelpFlag)
|
.setting(AppSettings::DisableHelpFlag)
|
||||||
.setting(AppSettings::DisableVersion)
|
.setting(AppSettings::DisableVersionFlag)
|
||||||
.after_help("This is after help.");
|
.after_help("This is after help.");
|
||||||
|
|
||||||
let help = {
|
let help = {
|
||||||
|
|
Loading…
Add table
Reference in a new issue