mirror of
https://github.com/clap-rs/clap
synced 2024-12-14 14:52:33 +00:00
commit
ac0f59ef73
21 changed files with 196 additions and 166 deletions
|
@ -55,7 +55,7 @@ fn build_cli() -> App<'static> {
|
||||||
Arg::new("no-self-update")
|
Arg::new("no-self-update")
|
||||||
.help("Don't perform self update when running the `rustup` command")
|
.help("Don't perform self update when running the `rustup` command")
|
||||||
.long("no-self-update")
|
.long("no-self-update")
|
||||||
.hidden(true),
|
.hide(true),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
.subcommand(
|
.subcommand(
|
||||||
|
|
|
@ -15,7 +15,7 @@ enum ArgChoice {
|
||||||
#[clap(alias = "b", alias = "z")]
|
#[clap(alias = "b", alias = "z")]
|
||||||
Baz,
|
Baz,
|
||||||
// Hiding variants from help and completion is supported
|
// Hiding variants from help and completion is supported
|
||||||
#[clap(hidden = true)]
|
#[clap(hide = true)]
|
||||||
Hidden,
|
Hidden,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -837,8 +837,8 @@ impl Attrs {
|
||||||
self.is_enum
|
self.is_enum
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn case_insensitive(&self) -> TokenStream {
|
pub fn ignore_case(&self) -> TokenStream {
|
||||||
let method = self.find_method("case_insensitive");
|
let method = self.find_method("ignore_case");
|
||||||
|
|
||||||
if let Some(method) = method {
|
if let Some(method) = method {
|
||||||
method.args.clone()
|
method.args.clone()
|
||||||
|
|
|
@ -558,7 +558,7 @@ fn gen_parsers(
|
||||||
FromFlag => (quote!(), quote!(), func.clone()),
|
FromFlag => (quote!(), quote!(), func.clone()),
|
||||||
};
|
};
|
||||||
if attrs.is_enum() {
|
if attrs.is_enum() {
|
||||||
let ci = attrs.case_insensitive();
|
let ci = attrs.ignore_case();
|
||||||
|
|
||||||
parse = quote_spanned! { convert_type.span()=>
|
parse = quote_spanned! { convert_type.span()=>
|
||||||
|s| <#convert_type as clap::ArgEnum>::from_str(s, #ci).map_err(|err| clap::Error::raw(clap::ErrorKind::ValueValidation, format!("Invalid value for {}: {}", #name, err)))
|
|s| <#convert_type as clap::ArgEnum>::from_str(s, #ci).map_err(|err| clap::Error::raw(clap::ErrorKind::ValueValidation, format!("Invalid value for {}: {}", #name, err)))
|
||||||
|
|
|
@ -79,7 +79,7 @@ pub fn arg_enum(name: &Ident) {
|
||||||
fn value_variants<'a>() -> &'a [Self]{
|
fn value_variants<'a>() -> &'a [Self]{
|
||||||
unimplemented!()
|
unimplemented!()
|
||||||
}
|
}
|
||||||
fn from_str(_input: &str, _case_insensitive: bool) -> Result<Self, String> {
|
fn from_str(_input: &str, _ignore_case: bool) -> Result<Self, String> {
|
||||||
unimplemented!()
|
unimplemented!()
|
||||||
}
|
}
|
||||||
fn to_possible_value<'a>(&self) -> Option<clap::PossibleValue<'a>>{
|
fn to_possible_value<'a>(&self) -> Option<clap::PossibleValue<'a>>{
|
||||||
|
|
|
@ -186,7 +186,7 @@ fn casing_propagation_is_overridden() {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn case_insensitive() {
|
fn ignore_case() {
|
||||||
#[derive(ArgEnum, PartialEq, Debug, Clone)]
|
#[derive(ArgEnum, PartialEq, Debug, Clone)]
|
||||||
enum ArgChoice {
|
enum ArgChoice {
|
||||||
Foo,
|
Foo,
|
||||||
|
@ -194,7 +194,7 @@ fn case_insensitive() {
|
||||||
|
|
||||||
#[derive(Parser, PartialEq, Debug)]
|
#[derive(Parser, PartialEq, Debug)]
|
||||||
struct Opt {
|
struct Opt {
|
||||||
#[clap(arg_enum, case_insensitive(true))]
|
#[clap(arg_enum, ignore_case(true))]
|
||||||
arg: ArgChoice,
|
arg: ArgChoice,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -213,7 +213,7 @@ fn case_insensitive() {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn case_insensitive_set_to_false() {
|
fn ignore_case_set_to_false() {
|
||||||
#[derive(ArgEnum, PartialEq, Debug, Clone)]
|
#[derive(ArgEnum, PartialEq, Debug, Clone)]
|
||||||
enum ArgChoice {
|
enum ArgChoice {
|
||||||
Foo,
|
Foo,
|
||||||
|
@ -221,7 +221,7 @@ fn case_insensitive_set_to_false() {
|
||||||
|
|
||||||
#[derive(Parser, PartialEq, Debug)]
|
#[derive(Parser, PartialEq, Debug)]
|
||||||
struct Opt {
|
struct Opt {
|
||||||
#[clap(arg_enum, case_insensitive(false))]
|
#[clap(arg_enum, ignore_case(false))]
|
||||||
arg: ArgChoice,
|
arg: ArgChoice,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -244,7 +244,7 @@ fn alias() {
|
||||||
|
|
||||||
#[derive(Parser, PartialEq, Debug)]
|
#[derive(Parser, PartialEq, Debug)]
|
||||||
struct Opt {
|
struct Opt {
|
||||||
#[clap(arg_enum, case_insensitive(false))]
|
#[clap(arg_enum, ignore_case(false))]
|
||||||
arg: ArgChoice,
|
arg: ArgChoice,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -272,7 +272,7 @@ fn multiple_alias() {
|
||||||
|
|
||||||
#[derive(Parser, PartialEq, Debug)]
|
#[derive(Parser, PartialEq, Debug)]
|
||||||
struct Opt {
|
struct Opt {
|
||||||
#[clap(arg_enum, case_insensitive(false))]
|
#[clap(arg_enum, ignore_case(false))]
|
||||||
arg: ArgChoice,
|
arg: ArgChoice,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@ use clap::Parser;
|
||||||
|
|
||||||
#[derive(Parser, Debug)]
|
#[derive(Parser, Debug)]
|
||||||
struct Opt {
|
struct Opt {
|
||||||
#[clap(raw(case_insensitive = "true"))]
|
#[clap(raw(ignore_case = "true"))]
|
||||||
s: String,
|
s: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
error: `#[clap(raw(...))` attributes are removed, they are replaced with raw methods
|
error: `#[clap(raw(...))` attributes are removed, they are replaced with raw methods
|
||||||
|
|
||||||
= help: if you meant to call `clap::Arg::raw()` method you should use bool literal, like `raw(true)` or `raw(false)`
|
= help: if you meant to call `clap::Arg::raw()` method you should use bool literal, like `raw(true)` or `raw(false)`
|
||||||
= note: if you need to call `clap::Arg/App::case_insensitive` method you can do it like this: #[clap(case_insensitive = true)]
|
= note: if you need to call `clap::Arg/App::ignore_case` method you can do it like this: #[clap(ignore_case = true)]
|
||||||
|
|
||||||
--> $DIR/raw.rs:13:12
|
--> $DIR/raw.rs:13:12
|
||||||
|
|
|
|
||||||
13 | #[clap(raw(case_insensitive = "true"))]
|
13 | #[clap(raw(ignore_case = "true"))]
|
||||||
| ^^^
|
| ^^^
|
||||||
|
|
||||||
error: `#[clap(raw(...))` attributes are removed, they are replaced with raw methods
|
error: `#[clap(raw(...))` attributes are removed, they are replaced with raw methods
|
||||||
|
|
|
@ -113,6 +113,8 @@ impl_settings! { AppSettings, AppFlags,
|
||||||
=> Flags::PROPAGATE_VERSION,
|
=> Flags::PROPAGATE_VERSION,
|
||||||
GlobalVersion("propagateversion")
|
GlobalVersion("propagateversion")
|
||||||
=> Flags::PROPAGATE_VERSION,
|
=> Flags::PROPAGATE_VERSION,
|
||||||
|
HidePossibleValues("hidepossiblevalues")
|
||||||
|
=> Flags::NO_POS_VALUES,
|
||||||
HidePossibleValuesInHelp("hidepossiblevaluesinhelp")
|
HidePossibleValuesInHelp("hidepossiblevaluesinhelp")
|
||||||
=> Flags::NO_POS_VALUES,
|
=> Flags::NO_POS_VALUES,
|
||||||
HelpExpected("helpexpected")
|
HelpExpected("helpexpected")
|
||||||
|
@ -786,6 +788,12 @@ pub enum AppSettings {
|
||||||
///
|
///
|
||||||
/// To set this per argument, see
|
/// To set this per argument, see
|
||||||
/// [`Arg::hide_possible_values`][crate::Arg::hide_possible_values].
|
/// [`Arg::hide_possible_values`][crate::Arg::hide_possible_values].
|
||||||
|
HidePossibleValues,
|
||||||
|
/// Deprecated, replaced with [`AppSettings::HidePossibleValues`]
|
||||||
|
#[deprecated(
|
||||||
|
since = "3.0.0",
|
||||||
|
note = "Replaced with AppSettings::HidePossibleValues"
|
||||||
|
)]
|
||||||
HidePossibleValuesInHelp,
|
HidePossibleValuesInHelp,
|
||||||
|
|
||||||
/// Panic if help descriptions are omitted.
|
/// Panic if help descriptions are omitted.
|
||||||
|
@ -1195,8 +1203,8 @@ mod test {
|
||||||
AppSettings::Hidden
|
AppSettings::Hidden
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
"hidepossiblevaluesinhelp".parse::<AppSettings>().unwrap(),
|
"hidepossiblevalues".parse::<AppSettings>().unwrap(),
|
||||||
AppSettings::HidePossibleValuesInHelp
|
AppSettings::HidePossibleValues
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
"helpexpected".parse::<AppSettings>().unwrap(),
|
"helpexpected".parse::<AppSettings>().unwrap(),
|
||||||
|
|
|
@ -390,9 +390,9 @@ impl<'help> Arg<'help> {
|
||||||
"global" => yaml_to_bool!(a, v, global),
|
"global" => yaml_to_bool!(a, v, global),
|
||||||
"multiple_occurrences" => yaml_to_bool!(a, v, multiple_occurrences),
|
"multiple_occurrences" => yaml_to_bool!(a, v, multiple_occurrences),
|
||||||
"multiple_values" => yaml_to_bool!(a, v, multiple_values),
|
"multiple_values" => yaml_to_bool!(a, v, multiple_values),
|
||||||
"hidden" => yaml_to_bool!(a, v, hidden),
|
"hide" => yaml_to_bool!(a, v, hide),
|
||||||
"hidden_long_help" => yaml_to_bool!(a, v, hidden_long_help),
|
"hide_long_help" => yaml_to_bool!(a, v, hide_long_help),
|
||||||
"hidden_short_help" => yaml_to_bool!(a, v, hidden_short_help),
|
"hide_short_help" => yaml_to_bool!(a, v, hide_short_help),
|
||||||
"next_line_help" => yaml_to_bool!(a, v, next_line_help),
|
"next_line_help" => yaml_to_bool!(a, v, next_line_help),
|
||||||
"group" => yaml_to_str!(a, v, group),
|
"group" => yaml_to_str!(a, v, group),
|
||||||
"number_of_values" => yaml_to_usize!(a, v, number_of_values),
|
"number_of_values" => yaml_to_usize!(a, v, number_of_values),
|
||||||
|
@ -434,7 +434,7 @@ impl<'help> Arg<'help> {
|
||||||
"overrides_with_all" => yaml_vec_or_str!(a, v, overrides_with),
|
"overrides_with_all" => yaml_vec_or_str!(a, v, overrides_with),
|
||||||
"possible_value" => yaml_to_str!(a, v, possible_value),
|
"possible_value" => yaml_to_str!(a, v, possible_value),
|
||||||
"possible_values" => yaml_vec_or_str!(a, v, possible_value),
|
"possible_values" => yaml_vec_or_str!(a, v, possible_value),
|
||||||
"case_insensitive" => yaml_to_bool!(a, v, case_insensitive),
|
"ignore_case" => yaml_to_bool!(a, v, ignore_case),
|
||||||
"required_unless_present_any" => yaml_vec!(a, v, required_unless_present_any),
|
"required_unless_present_any" => yaml_vec!(a, v, required_unless_present_any),
|
||||||
"required_unless_present_all" => yaml_vec!(a, v, required_unless_present_all),
|
"required_unless_present_all" => yaml_vec!(a, v, required_unless_present_all),
|
||||||
"visible_alias" => yaml_to_str!(a, v, visible_alias),
|
"visible_alias" => yaml_to_str!(a, v, visible_alias),
|
||||||
|
@ -1252,8 +1252,8 @@ impl<'help> Arg<'help> {
|
||||||
/// assert_eq!(res.unwrap_err().kind, ErrorKind::ArgumentConflict);
|
/// assert_eq!(res.unwrap_err().kind, ErrorKind::ArgumentConflict);
|
||||||
/// ```
|
/// ```
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn exclusive(mut self, exclusive: bool) -> Self {
|
pub fn exclusive(mut self, yes: bool) -> Self {
|
||||||
self.exclusive = exclusive;
|
self.exclusive = yes;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1642,7 +1642,7 @@ impl<'help> Arg<'help> {
|
||||||
/// .long("config"))
|
/// .long("config"))
|
||||||
/// .arg(Arg::new("other")
|
/// .arg(Arg::new("other")
|
||||||
/// .long("other")
|
/// .long("other")
|
||||||
/// .case_insensitive(true)
|
/// .ignore_case(true)
|
||||||
/// .takes_value(true))
|
/// .takes_value(true))
|
||||||
/// .try_get_matches_from(vec![
|
/// .try_get_matches_from(vec![
|
||||||
/// "prog", "--other", "SPECIAL"
|
/// "prog", "--other", "SPECIAL"
|
||||||
|
@ -2311,8 +2311,8 @@ impl<'help> Arg<'help> {
|
||||||
/// [`ArgMatches::value_of_lossy`]: crate::ArgMatches::value_of_lossy()
|
/// [`ArgMatches::value_of_lossy`]: crate::ArgMatches::value_of_lossy()
|
||||||
/// [`ArgMatches::values_of_lossy`]: crate::ArgMatches::values_of_lossy()
|
/// [`ArgMatches::values_of_lossy`]: crate::ArgMatches::values_of_lossy()
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn allow_invalid_utf8(self, tv: bool) -> Self {
|
pub fn allow_invalid_utf8(self, yes: bool) -> Self {
|
||||||
if tv {
|
if yes {
|
||||||
self.setting(ArgSettings::AllowInvalidUtf8)
|
self.setting(ArgSettings::AllowInvalidUtf8)
|
||||||
} else {
|
} else {
|
||||||
self.unset_setting(ArgSettings::AllowInvalidUtf8)
|
self.unset_setting(ArgSettings::AllowInvalidUtf8)
|
||||||
|
@ -3537,8 +3537,8 @@ impl<'help> Arg<'help> {
|
||||||
/// [index]: Arg::index()
|
/// [index]: Arg::index()
|
||||||
/// [`UnknownArgument`]: crate::ErrorKind::UnknownArgument
|
/// [`UnknownArgument`]: crate::ErrorKind::UnknownArgument
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn last(self, l: bool) -> Self {
|
pub fn last(self, yes: bool) -> Self {
|
||||||
if l {
|
if yes {
|
||||||
self.setting(ArgSettings::Last)
|
self.setting(ArgSettings::Last)
|
||||||
} else {
|
} else {
|
||||||
self.unset_setting(ArgSettings::Last)
|
self.unset_setting(ArgSettings::Last)
|
||||||
|
@ -3599,8 +3599,8 @@ impl<'help> Arg<'help> {
|
||||||
/// assert_eq!(res.unwrap_err().kind, ErrorKind::MissingRequiredArgument);
|
/// assert_eq!(res.unwrap_err().kind, ErrorKind::MissingRequiredArgument);
|
||||||
/// ```
|
/// ```
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn required(self, r: bool) -> Self {
|
pub fn required(self, yes: bool) -> Self {
|
||||||
if r {
|
if yes {
|
||||||
self.setting(ArgSettings::Required)
|
self.setting(ArgSettings::Required)
|
||||||
} else {
|
} else {
|
||||||
self.unset_setting(ArgSettings::Required)
|
self.unset_setting(ArgSettings::Required)
|
||||||
|
@ -3639,8 +3639,8 @@ impl<'help> Arg<'help> {
|
||||||
/// [`Arg::value_delimiter(char)`]: Arg::value_delimiter()
|
/// [`Arg::value_delimiter(char)`]: Arg::value_delimiter()
|
||||||
/// [multiple values]: Arg::multiple_values
|
/// [multiple values]: Arg::multiple_values
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn takes_value(self, tv: bool) -> Self {
|
pub fn takes_value(self, yes: bool) -> Self {
|
||||||
if tv {
|
if yes {
|
||||||
self.setting(ArgSettings::TakesValue)
|
self.setting(ArgSettings::TakesValue)
|
||||||
} else {
|
} else {
|
||||||
self.unset_setting(ArgSettings::TakesValue)
|
self.unset_setting(ArgSettings::TakesValue)
|
||||||
|
@ -3698,8 +3698,8 @@ impl<'help> Arg<'help> {
|
||||||
/// ```
|
/// ```
|
||||||
/// [`Arg::number_of_values(1)`]: Arg::number_of_values()
|
/// [`Arg::number_of_values(1)`]: Arg::number_of_values()
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn allow_hyphen_values(self, a: bool) -> Self {
|
pub fn allow_hyphen_values(self, yes: bool) -> Self {
|
||||||
if a {
|
if yes {
|
||||||
self.setting(ArgSettings::AllowHyphenValues)
|
self.setting(ArgSettings::AllowHyphenValues)
|
||||||
} else {
|
} else {
|
||||||
self.unset_setting(ArgSettings::AllowHyphenValues)
|
self.unset_setting(ArgSettings::AllowHyphenValues)
|
||||||
|
@ -3749,8 +3749,8 @@ impl<'help> Arg<'help> {
|
||||||
/// assert_eq!(res.unwrap_err().kind, ErrorKind::NoEquals);
|
/// assert_eq!(res.unwrap_err().kind, ErrorKind::NoEquals);
|
||||||
/// ```
|
/// ```
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn require_equals(self, r: bool) -> Self {
|
pub fn require_equals(self, yes: bool) -> Self {
|
||||||
if r {
|
if yes {
|
||||||
self.setting(ArgSettings::RequireEquals)
|
self.setting(ArgSettings::RequireEquals)
|
||||||
} else {
|
} else {
|
||||||
self.unset_setting(ArgSettings::RequireEquals)
|
self.unset_setting(ArgSettings::RequireEquals)
|
||||||
|
@ -3791,8 +3791,8 @@ impl<'help> Arg<'help> {
|
||||||
/// [`Subcommand`]: crate::Subcommand
|
/// [`Subcommand`]: crate::Subcommand
|
||||||
/// [`ArgMatches::is_present("flag")`]: ArgMatches::is_present()
|
/// [`ArgMatches::is_present("flag")`]: ArgMatches::is_present()
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn global(mut self, g: bool) -> Self {
|
pub fn global(mut self, yes: bool) -> Self {
|
||||||
self.global = g;
|
self.global = yes;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3873,8 +3873,8 @@ impl<'help> Arg<'help> {
|
||||||
/// assert_eq!(delims.values_of("opt").unwrap().collect::<Vec<_>>(), ["val1", "val2", "val3"]);
|
/// assert_eq!(delims.values_of("opt").unwrap().collect::<Vec<_>>(), ["val1", "val2", "val3"]);
|
||||||
/// ```
|
/// ```
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn require_delimiter(self, d: bool) -> Self {
|
pub fn require_delimiter(self, yes: bool) -> Self {
|
||||||
if d {
|
if yes {
|
||||||
self.setting(ArgSettings::RequireDelimiter)
|
self.setting(ArgSettings::RequireDelimiter)
|
||||||
} else {
|
} else {
|
||||||
self.unset_setting(ArgSettings::RequireDelimiter)
|
self.unset_setting(ArgSettings::RequireDelimiter)
|
||||||
|
@ -3889,7 +3889,7 @@ impl<'help> Arg<'help> {
|
||||||
/// **NOTE:** Setting this requires [`Arg::takes_value`]
|
/// **NOTE:** Setting this requires [`Arg::takes_value`]
|
||||||
///
|
///
|
||||||
/// To set this for all arguments, see
|
/// To set this for all arguments, see
|
||||||
/// [`AppSettings::HidePossibleValuesInHelp`][crate::AppSettings::HidePossibleValuesInHelp].
|
/// [`AppSettings::HidePossibleValues`][crate::AppSettings::HidePossibleValues].
|
||||||
///
|
///
|
||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
|
@ -3905,8 +3905,8 @@ impl<'help> Arg<'help> {
|
||||||
/// If we were to run the above program with `--help` the `[values: fast, slow]` portion of
|
/// If we were to run the above program with `--help` the `[values: fast, slow]` portion of
|
||||||
/// the help text would be omitted.
|
/// the help text would be omitted.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn hide_possible_values(self, hide: bool) -> Self {
|
pub fn hide_possible_values(self, yes: bool) -> Self {
|
||||||
if hide {
|
if yes {
|
||||||
self.setting(ArgSettings::HidePossibleValues)
|
self.setting(ArgSettings::HidePossibleValues)
|
||||||
} else {
|
} else {
|
||||||
self.unset_setting(ArgSettings::HidePossibleValues)
|
self.unset_setting(ArgSettings::HidePossibleValues)
|
||||||
|
@ -3935,8 +3935,8 @@ impl<'help> Arg<'help> {
|
||||||
/// If we were to run the above program with `--help` the `[default: localhost]` portion of
|
/// If we were to run the above program with `--help` the `[default: localhost]` portion of
|
||||||
/// the help text would be omitted.
|
/// the help text would be omitted.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn hide_default_value(self, hide: bool) -> Self {
|
pub fn hide_default_value(self, yes: bool) -> Self {
|
||||||
if hide {
|
if yes {
|
||||||
self.setting(ArgSettings::HideDefaultValue)
|
self.setting(ArgSettings::HideDefaultValue)
|
||||||
} else {
|
} else {
|
||||||
self.unset_setting(ArgSettings::HideDefaultValue)
|
self.unset_setting(ArgSettings::HideDefaultValue)
|
||||||
|
@ -3976,14 +3976,21 @@ impl<'help> Arg<'help> {
|
||||||
/// -V, --version Print version information
|
/// -V, --version Print version information
|
||||||
/// ```
|
/// ```
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn hidden(self, h: bool) -> Self {
|
pub fn hide(self, yes: bool) -> Self {
|
||||||
if h {
|
if yes {
|
||||||
self.setting(ArgSettings::Hidden)
|
self.setting(ArgSettings::Hidden)
|
||||||
} else {
|
} else {
|
||||||
self.unset_setting(ArgSettings::Hidden)
|
self.unset_setting(ArgSettings::Hidden)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Deprecated, replaced with [`Arg::hide`]
|
||||||
|
#[deprecated(since = "3.0.0", note = "Replaced with `Arg::hide`")]
|
||||||
|
#[inline]
|
||||||
|
pub fn hidden(self, yes: bool) -> Self {
|
||||||
|
self.hide(yes)
|
||||||
|
}
|
||||||
|
|
||||||
/// Match values against [`Arg::possible_values`] without matching case.
|
/// Match values against [`Arg::possible_values`] without matching case.
|
||||||
///
|
///
|
||||||
/// When other arguments are conditionally required based on the
|
/// When other arguments are conditionally required based on the
|
||||||
|
@ -4004,7 +4011,7 @@ impl<'help> Arg<'help> {
|
||||||
/// .arg(Arg::new("option")
|
/// .arg(Arg::new("option")
|
||||||
/// .long("--option")
|
/// .long("--option")
|
||||||
/// .takes_value(true)
|
/// .takes_value(true)
|
||||||
/// .case_insensitive(true)
|
/// .ignore_case(true)
|
||||||
/// .possible_value("test123"))
|
/// .possible_value("test123"))
|
||||||
/// .get_matches_from(vec![
|
/// .get_matches_from(vec![
|
||||||
/// "pv", "--option", "TeSt123",
|
/// "pv", "--option", "TeSt123",
|
||||||
|
@ -4022,7 +4029,7 @@ impl<'help> Arg<'help> {
|
||||||
/// .short('o')
|
/// .short('o')
|
||||||
/// .long("--option")
|
/// .long("--option")
|
||||||
/// .takes_value(true)
|
/// .takes_value(true)
|
||||||
/// .case_insensitive(true)
|
/// .ignore_case(true)
|
||||||
/// .multiple_values(true)
|
/// .multiple_values(true)
|
||||||
/// .possible_values(&["test123", "test321"]))
|
/// .possible_values(&["test123", "test321"]))
|
||||||
/// .get_matches_from(vec![
|
/// .get_matches_from(vec![
|
||||||
|
@ -4033,14 +4040,21 @@ impl<'help> Arg<'help> {
|
||||||
/// assert_eq!(&*matched_vals, &["TeSt123", "teST123", "tESt321"]);
|
/// assert_eq!(&*matched_vals, &["TeSt123", "teST123", "tESt321"]);
|
||||||
/// ```
|
/// ```
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn case_insensitive(self, ci: bool) -> Self {
|
pub fn ignore_case(self, yes: bool) -> Self {
|
||||||
if ci {
|
if yes {
|
||||||
self.setting(ArgSettings::IgnoreCase)
|
self.setting(ArgSettings::IgnoreCase)
|
||||||
} else {
|
} else {
|
||||||
self.unset_setting(ArgSettings::IgnoreCase)
|
self.unset_setting(ArgSettings::IgnoreCase)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Deprecated, replaced with [`Arg::ignore_case`]
|
||||||
|
#[deprecated(since = "3.0.0", note = "Replaced with `Arg::ignore_case`")]
|
||||||
|
#[inline]
|
||||||
|
pub fn case_insensitive(self, yes: bool) -> Self {
|
||||||
|
self.ignore_case(yes)
|
||||||
|
}
|
||||||
|
|
||||||
/// Specifies that an argument should allow grouping of multiple values via a
|
/// Specifies that an argument should allow grouping of multiple values via a
|
||||||
/// delimiter.
|
/// delimiter.
|
||||||
///
|
///
|
||||||
|
@ -4091,8 +4105,8 @@ impl<'help> Arg<'help> {
|
||||||
/// ```
|
/// ```
|
||||||
/// [`Arg::value_delimiter`]: Arg::value_delimiter()
|
/// [`Arg::value_delimiter`]: Arg::value_delimiter()
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn use_delimiter(mut self, d: bool) -> Self {
|
pub fn use_delimiter(mut self, yes: bool) -> Self {
|
||||||
if d {
|
if yes {
|
||||||
if self.val_delim.is_none() {
|
if self.val_delim.is_none() {
|
||||||
self.val_delim = Some(',');
|
self.val_delim = Some(',');
|
||||||
}
|
}
|
||||||
|
@ -4124,8 +4138,8 @@ impl<'help> Arg<'help> {
|
||||||
/// text would be omitted.
|
/// text would be omitted.
|
||||||
#[cfg(feature = "env")]
|
#[cfg(feature = "env")]
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn hide_env(self, hide: bool) -> Self {
|
pub fn hide_env(self, yes: bool) -> Self {
|
||||||
if hide {
|
if yes {
|
||||||
self.setting(ArgSettings::HideEnv)
|
self.setting(ArgSettings::HideEnv)
|
||||||
} else {
|
} else {
|
||||||
self.unset_setting(ArgSettings::HideEnv)
|
self.unset_setting(ArgSettings::HideEnv)
|
||||||
|
@ -4153,8 +4167,8 @@ impl<'help> Arg<'help> {
|
||||||
/// `[default: CONNECT=super_secret]` portion of the help text would be omitted.
|
/// `[default: CONNECT=super_secret]` portion of the help text would be omitted.
|
||||||
#[cfg(feature = "env")]
|
#[cfg(feature = "env")]
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn hide_env_values(self, hide: bool) -> Self {
|
pub fn hide_env_values(self, yes: bool) -> Self {
|
||||||
if hide {
|
if yes {
|
||||||
self.setting(ArgSettings::HideEnvValues)
|
self.setting(ArgSettings::HideEnvValues)
|
||||||
} else {
|
} else {
|
||||||
self.unset_setting(ArgSettings::HideEnvValues)
|
self.unset_setting(ArgSettings::HideEnvValues)
|
||||||
|
@ -4205,8 +4219,8 @@ impl<'help> Arg<'help> {
|
||||||
/// on a line after the option
|
/// on a line after the option
|
||||||
/// ```
|
/// ```
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn next_line_help(self, nlh: bool) -> Self {
|
pub fn next_line_help(self, yes: bool) -> Self {
|
||||||
if nlh {
|
if yes {
|
||||||
self.setting(ArgSettings::NextLineHelp)
|
self.setting(ArgSettings::NextLineHelp)
|
||||||
} else {
|
} else {
|
||||||
self.unset_setting(ArgSettings::NextLineHelp)
|
self.unset_setting(ArgSettings::NextLineHelp)
|
||||||
|
@ -4259,8 +4273,8 @@ impl<'help> Arg<'help> {
|
||||||
/// assert_eq!(res.unwrap_err().kind, ErrorKind::EmptyValue);
|
/// assert_eq!(res.unwrap_err().kind, ErrorKind::EmptyValue);
|
||||||
/// ```
|
/// ```
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn forbid_empty_values(self, empty: bool) -> Self {
|
pub fn forbid_empty_values(self, yes: bool) -> Self {
|
||||||
if empty {
|
if yes {
|
||||||
self.setting(ArgSettings::ForbidEmptyValues)
|
self.setting(ArgSettings::ForbidEmptyValues)
|
||||||
} else {
|
} else {
|
||||||
self.unset_setting(ArgSettings::ForbidEmptyValues)
|
self.unset_setting(ArgSettings::ForbidEmptyValues)
|
||||||
|
@ -4269,8 +4283,8 @@ impl<'help> Arg<'help> {
|
||||||
|
|
||||||
/// Deprecated, replaced with [`Arg::forbid_empty_values`]
|
/// Deprecated, replaced with [`Arg::forbid_empty_values`]
|
||||||
#[deprecated(since = "3.0.0", note = "Replaced with `Arg::forbid_empty_values`")]
|
#[deprecated(since = "3.0.0", note = "Replaced with `Arg::forbid_empty_values`")]
|
||||||
pub fn empty_values(self, empty: bool) -> Self {
|
pub fn empty_values(self, yes: bool) -> Self {
|
||||||
self.forbid_empty_values(!empty)
|
self.forbid_empty_values(!yes)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Specifies that the argument may have an unknown number of values
|
/// Specifies that the argument may have an unknown number of values
|
||||||
|
@ -4439,8 +4453,8 @@ impl<'help> Arg<'help> {
|
||||||
/// [maximum]: Arg::max_values()
|
/// [maximum]: Arg::max_values()
|
||||||
/// [specific]: Arg::number_of_values()
|
/// [specific]: Arg::number_of_values()
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn multiple_values(self, multi: bool) -> Self {
|
pub fn multiple_values(self, yes: bool) -> Self {
|
||||||
if multi {
|
if yes {
|
||||||
self.setting(ArgSettings::MultipleValues)
|
self.setting(ArgSettings::MultipleValues)
|
||||||
} else {
|
} else {
|
||||||
self.unset_setting(ArgSettings::MultipleValues)
|
self.unset_setting(ArgSettings::MultipleValues)
|
||||||
|
@ -4493,8 +4507,8 @@ impl<'help> Arg<'help> {
|
||||||
/// assert_eq!(files, ["file1", "file2", "file3"]);
|
/// assert_eq!(files, ["file1", "file2", "file3"]);
|
||||||
/// ```
|
/// ```
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn multiple_occurrences(self, multi: bool) -> Self {
|
pub fn multiple_occurrences(self, yes: bool) -> Self {
|
||||||
if multi {
|
if yes {
|
||||||
self.setting(ArgSettings::MultipleOccurrences)
|
self.setting(ArgSettings::MultipleOccurrences)
|
||||||
} else {
|
} else {
|
||||||
self.unset_setting(ArgSettings::MultipleOccurrences)
|
self.unset_setting(ArgSettings::MultipleOccurrences)
|
||||||
|
@ -4507,8 +4521,8 @@ impl<'help> Arg<'help> {
|
||||||
since = "3.0.0",
|
since = "3.0.0",
|
||||||
note = "Split into `Arg::multiple_occurrences` (most likely what you want) and `Arg::multiple_values`"
|
note = "Split into `Arg::multiple_occurrences` (most likely what you want) and `Arg::multiple_values`"
|
||||||
)]
|
)]
|
||||||
pub fn multiple(self, multi: bool) -> Self {
|
pub fn multiple(self, yes: bool) -> Self {
|
||||||
self.multiple_occurrences(multi).multiple_values(multi)
|
self.multiple_occurrences(yes).multiple_values(yes)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Consume all following arguments.
|
/// Consume all following arguments.
|
||||||
|
@ -4534,11 +4548,11 @@ impl<'help> Arg<'help> {
|
||||||
/// [`Arg::allow_hyphen_values(true)`]: Arg::allow_hyphen_values()
|
/// [`Arg::allow_hyphen_values(true)`]: Arg::allow_hyphen_values()
|
||||||
/// [`Arg::last(true)`]: Arg::last()
|
/// [`Arg::last(true)`]: Arg::last()
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn raw(self, raw: bool) -> Self {
|
pub fn raw(self, yes: bool) -> Self {
|
||||||
self.takes_value(raw)
|
self.takes_value(yes)
|
||||||
.multiple_values(raw)
|
.multiple_values(yes)
|
||||||
.allow_hyphen_values(raw)
|
.allow_hyphen_values(yes)
|
||||||
.last(raw)
|
.last(yes)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Hides an argument from short help (`-h`).
|
/// Hides an argument from short help (`-h`).
|
||||||
|
@ -4553,17 +4567,17 @@ impl<'help> Arg<'help> {
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # use clap::{App, Arg};
|
/// # use clap::{App, Arg};
|
||||||
/// Arg::new("debug")
|
/// Arg::new("debug")
|
||||||
/// .hidden_short_help(true);
|
/// .hide_short_help(true);
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
/// Setting `hidden_short_help(true)` will hide the argument when displaying short help text
|
/// Setting `hide_short_help(true)` will hide the argument when displaying short help text
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # use clap::{App, Arg};
|
/// # use clap::{App, Arg};
|
||||||
/// let m = App::new("prog")
|
/// let m = App::new("prog")
|
||||||
/// .arg(Arg::new("cfg")
|
/// .arg(Arg::new("cfg")
|
||||||
/// .long("config")
|
/// .long("config")
|
||||||
/// .hidden_short_help(true)
|
/// .hide_short_help(true)
|
||||||
/// .help("Some help text describing the --config arg"))
|
/// .help("Some help text describing the --config arg"))
|
||||||
/// .get_matches_from(vec![
|
/// .get_matches_from(vec![
|
||||||
/// "prog", "-h"
|
/// "prog", "-h"
|
||||||
|
@ -4590,7 +4604,7 @@ impl<'help> Arg<'help> {
|
||||||
/// let m = App::new("prog")
|
/// let m = App::new("prog")
|
||||||
/// .arg(Arg::new("cfg")
|
/// .arg(Arg::new("cfg")
|
||||||
/// .long("config")
|
/// .long("config")
|
||||||
/// .hidden_short_help(true)
|
/// .hide_short_help(true)
|
||||||
/// .help("Some help text describing the --config arg"))
|
/// .help("Some help text describing the --config arg"))
|
||||||
/// .get_matches_from(vec![
|
/// .get_matches_from(vec![
|
||||||
/// "prog", "--help"
|
/// "prog", "--help"
|
||||||
|
@ -4611,14 +4625,21 @@ impl<'help> Arg<'help> {
|
||||||
/// -V, --version Print version information
|
/// -V, --version Print version information
|
||||||
/// ```
|
/// ```
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn hidden_short_help(self, hide: bool) -> Self {
|
pub fn hide_short_help(self, yes: bool) -> Self {
|
||||||
if hide {
|
if yes {
|
||||||
self.setting(ArgSettings::HiddenShortHelp)
|
self.setting(ArgSettings::HiddenShortHelp)
|
||||||
} else {
|
} else {
|
||||||
self.unset_setting(ArgSettings::HiddenShortHelp)
|
self.unset_setting(ArgSettings::HiddenShortHelp)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Deprecated, replaced with [`Arg::hide_short_help`]
|
||||||
|
#[deprecated(since = "3.0.0", note = "Replaced with `Arg::hide_short_help`")]
|
||||||
|
#[inline]
|
||||||
|
pub fn hidden_short_help(self, yes: bool) -> Self {
|
||||||
|
self.hide_short_help(yes)
|
||||||
|
}
|
||||||
|
|
||||||
/// Hides an argument from long help (`--help`).
|
/// Hides an argument from long help (`--help`).
|
||||||
///
|
///
|
||||||
/// **NOTE:** This does **not** hide the argument from usage strings on error
|
/// **NOTE:** This does **not** hide the argument from usage strings on error
|
||||||
|
@ -4628,20 +4649,14 @@ impl<'help> Arg<'help> {
|
||||||
///
|
///
|
||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// Setting `hide_long_help(true)` will hide the argument when displaying long help text
|
||||||
/// # use clap::{App, Arg};
|
|
||||||
/// Arg::new("debug")
|
|
||||||
/// .hidden_long_help(true)
|
|
||||||
/// # ;
|
|
||||||
/// ```
|
|
||||||
/// Setting `hidden_long_help(true)` will hide the argument when displaying long help text
|
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # use clap::{App, Arg};
|
/// # use clap::{App, Arg};
|
||||||
/// let m = App::new("prog")
|
/// let m = App::new("prog")
|
||||||
/// .arg(Arg::new("cfg")
|
/// .arg(Arg::new("cfg")
|
||||||
/// .long("config")
|
/// .long("config")
|
||||||
/// .hidden_long_help(true)
|
/// .hide_long_help(true)
|
||||||
/// .help("Some help text describing the --config arg"))
|
/// .help("Some help text describing the --config arg"))
|
||||||
/// .get_matches_from(vec![
|
/// .get_matches_from(vec![
|
||||||
/// "prog", "--help"
|
/// "prog", "--help"
|
||||||
|
@ -4668,7 +4683,7 @@ impl<'help> Arg<'help> {
|
||||||
/// let m = App::new("prog")
|
/// let m = App::new("prog")
|
||||||
/// .arg(Arg::new("cfg")
|
/// .arg(Arg::new("cfg")
|
||||||
/// .long("config")
|
/// .long("config")
|
||||||
/// .hidden_long_help(true)
|
/// .hide_long_help(true)
|
||||||
/// .help("Some help text describing the --config arg"))
|
/// .help("Some help text describing the --config arg"))
|
||||||
/// .get_matches_from(vec![
|
/// .get_matches_from(vec![
|
||||||
/// "prog", "-h"
|
/// "prog", "-h"
|
||||||
|
@ -4689,14 +4704,21 @@ impl<'help> Arg<'help> {
|
||||||
/// -V, --version Print version information
|
/// -V, --version Print version information
|
||||||
/// ```
|
/// ```
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn hidden_long_help(self, hide: bool) -> Self {
|
pub fn hide_long_help(self, yes: bool) -> Self {
|
||||||
if hide {
|
if yes {
|
||||||
self.setting(ArgSettings::HiddenLongHelp)
|
self.setting(ArgSettings::HiddenLongHelp)
|
||||||
} else {
|
} else {
|
||||||
self.unset_setting(ArgSettings::HiddenLongHelp)
|
self.unset_setting(ArgSettings::HiddenLongHelp)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Deprecated, replaced with [`Arg::hide_long_help`]
|
||||||
|
#[deprecated(since = "3.0.0", note = "Replaced with `Arg::hide_long_help`")]
|
||||||
|
#[inline]
|
||||||
|
pub fn hidden_long_help(self, yes: bool) -> Self {
|
||||||
|
self.hide_long_help(yes)
|
||||||
|
}
|
||||||
|
|
||||||
/// Check if the [`ArgSettings`] variant is currently set on the argument.
|
/// Check if the [`ArgSettings`] variant is currently set on the argument.
|
||||||
///
|
///
|
||||||
/// [`ArgSettings`]: crate::ArgSettings
|
/// [`ArgSettings`]: crate::ArgSettings
|
||||||
|
|
|
@ -18,18 +18,18 @@ use crate::util::eq_ignore_case;
|
||||||
/// .value_name("FILE")
|
/// .value_name("FILE")
|
||||||
/// .possible_value(PossibleValue::new("fast"))
|
/// .possible_value(PossibleValue::new("fast"))
|
||||||
/// .possible_value(PossibleValue::new("slow").help("slower than fast"))
|
/// .possible_value(PossibleValue::new("slow").help("slower than fast"))
|
||||||
/// .possible_value(PossibleValue::new("secret speed").hidden(true));
|
/// .possible_value(PossibleValue::new("secret speed").hide(true));
|
||||||
/// ```
|
/// ```
|
||||||
/// [Args]: crate::Arg
|
/// [Args]: crate::Arg
|
||||||
/// [possible values]: crate::Arg::possible_value()
|
/// [possible values]: crate::Arg::possible_value()
|
||||||
/// [hide]: PossibleValue::hidden()
|
/// [hide]: PossibleValue::hide()
|
||||||
/// [help]: PossibleValue::help()
|
/// [help]: PossibleValue::help()
|
||||||
#[derive(Debug, Default, Clone, PartialEq, Eq)]
|
#[derive(Debug, Default, Clone, PartialEq, Eq)]
|
||||||
pub struct PossibleValue<'help> {
|
pub struct PossibleValue<'help> {
|
||||||
pub(crate) name: &'help str,
|
pub(crate) name: &'help str,
|
||||||
pub(crate) help: Option<&'help str>,
|
pub(crate) help: Option<&'help str>,
|
||||||
pub(crate) aliases: Vec<&'help str>, // (name, visible)
|
pub(crate) aliases: Vec<&'help str>, // (name, visible)
|
||||||
pub(crate) hidden: bool,
|
pub(crate) hide: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'help> From<&'help str> for PossibleValue<'help> {
|
impl<'help> From<&'help str> for PossibleValue<'help> {
|
||||||
|
@ -61,12 +61,12 @@ impl<'help> PossibleValue<'help> {
|
||||||
/// Should the value be hidden from help messages and completion
|
/// Should the value be hidden from help messages and completion
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn is_hidden(&self) -> bool {
|
pub fn is_hidden(&self) -> bool {
|
||||||
self.hidden
|
self.hide
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get the name if argument value is not hidden, `None` otherwise
|
/// Get the name if argument value is not hidden, `None` otherwise
|
||||||
pub fn get_visible_name(&self) -> Option<&str> {
|
pub fn get_visible_name(&self) -> Option<&str> {
|
||||||
if self.hidden {
|
if self.hide {
|
||||||
None
|
None
|
||||||
} else {
|
} else {
|
||||||
Some(self.name)
|
Some(self.name)
|
||||||
|
@ -121,7 +121,7 @@ impl<'help> PossibleValue<'help> {
|
||||||
/// PossibleValue::new("fast")
|
/// PossibleValue::new("fast")
|
||||||
/// # ;
|
/// # ;
|
||||||
/// ```
|
/// ```
|
||||||
/// [hidden]: PossibleValue::hidden
|
/// [hidden]: PossibleValue::hide
|
||||||
/// [possible value]: crate::Arg::possible_values
|
/// [possible value]: crate::Arg::possible_values
|
||||||
/// [`Arg::hide_possible_values(true)`]: crate::Arg::hide_possible_values()
|
/// [`Arg::hide_possible_values(true)`]: crate::Arg::hide_possible_values()
|
||||||
pub fn new(name: &'help str) -> Self {
|
pub fn new(name: &'help str) -> Self {
|
||||||
|
@ -160,13 +160,13 @@ impl<'help> PossibleValue<'help> {
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # use clap::PossibleValue;
|
/// # use clap::PossibleValue;
|
||||||
/// PossibleValue::new("secret")
|
/// PossibleValue::new("secret")
|
||||||
/// .hidden(true)
|
/// .hide(true)
|
||||||
/// # ;
|
/// # ;
|
||||||
/// ```
|
/// ```
|
||||||
/// [`Arg::hide_possible_values(true)`]: crate::Arg::hide_possible_values()
|
/// [`Arg::hide_possible_values(true)`]: crate::Arg::hide_possible_values()
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn hidden(mut self, yes: bool) -> Self {
|
pub fn hide(mut self, yes: bool) -> Self {
|
||||||
self.hidden = yes;
|
self.hide = yes;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -238,8 +238,8 @@ impl<'help> ArgGroup<'help> {
|
||||||
///
|
///
|
||||||
/// [`Arg`]: crate::Arg
|
/// [`Arg`]: crate::Arg
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn multiple(mut self, m: bool) -> Self {
|
pub fn multiple(mut self, yes: bool) -> Self {
|
||||||
self.multiple = m;
|
self.multiple = yes;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -279,8 +279,8 @@ impl<'help> ArgGroup<'help> {
|
||||||
/// [`ArgGroup::multiple`]: ArgGroup::multiple()
|
/// [`ArgGroup::multiple`]: ArgGroup::multiple()
|
||||||
/// [`App`]: crate::App
|
/// [`App`]: crate::App
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn required(mut self, r: bool) -> Self {
|
pub fn required(mut self, yes: bool) -> Self {
|
||||||
self.required = r;
|
self.required = yes;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -313,13 +313,13 @@ pub trait ArgEnum: Sized + Clone {
|
||||||
fn value_variants<'a>() -> &'a [Self];
|
fn value_variants<'a>() -> &'a [Self];
|
||||||
|
|
||||||
/// Parse an argument into `Self`.
|
/// Parse an argument into `Self`.
|
||||||
fn from_str(input: &str, case_insensitive: bool) -> Result<Self, String> {
|
fn from_str(input: &str, ignore_case: bool) -> Result<Self, String> {
|
||||||
Self::value_variants()
|
Self::value_variants()
|
||||||
.iter()
|
.iter()
|
||||||
.find(|v| {
|
.find(|v| {
|
||||||
v.to_possible_value()
|
v.to_possible_value()
|
||||||
.expect("ArgEnum::value_variants contains only values with a corresponding ArgEnum::to_possible_value")
|
.expect("ArgEnum::value_variants contains only values with a corresponding ArgEnum::to_possible_value")
|
||||||
.matches(input, case_insensitive)
|
.matches(input, ignore_case)
|
||||||
})
|
})
|
||||||
.cloned()
|
.cloned()
|
||||||
.ok_or_else(|| format!("Invalid variant: {}", input))
|
.ok_or_else(|| format!("Invalid variant: {}", input))
|
||||||
|
|
|
@ -82,7 +82,7 @@ impl<'help, 'app, 'parser, 'writer> Help<'help, 'app, 'parser, 'writer> {
|
||||||
),
|
),
|
||||||
};
|
};
|
||||||
let next_line_help = parser.is_set(AppSettings::NextLineHelp);
|
let next_line_help = parser.is_set(AppSettings::NextLineHelp);
|
||||||
let hide_pv = parser.is_set(AppSettings::HidePossibleValuesInHelp);
|
let hide_pv = parser.is_set(AppSettings::HidePossibleValues);
|
||||||
|
|
||||||
Help {
|
Help {
|
||||||
writer,
|
writer,
|
||||||
|
|
|
@ -428,7 +428,7 @@ fn skip_possible_values() {
|
||||||
.author("Kevin K.")
|
.author("Kevin K.")
|
||||||
.about("tests stuff")
|
.about("tests stuff")
|
||||||
.version("1.3")
|
.version("1.3")
|
||||||
.setting(AppSettings::HidePossibleValuesInHelp)
|
.setting(AppSettings::HidePossibleValues)
|
||||||
.args(&[
|
.args(&[
|
||||||
arg!(-o --opt <opt> "some option")
|
arg!(-o --opt <opt> "some option")
|
||||||
.required(false)
|
.required(false)
|
||||||
|
|
6
tests/fixtures/app.yaml
vendored
6
tests/fixtures/app.yaml
vendored
|
@ -115,11 +115,11 @@ args:
|
||||||
long: exclusive
|
long: exclusive
|
||||||
help: Tests 3 exclusive
|
help: Tests 3 exclusive
|
||||||
exclusive: true
|
exclusive: true
|
||||||
- case_insensitive:
|
- ignore_case:
|
||||||
index: 4
|
index: 4
|
||||||
help: Test case_insensitive
|
help: Test ignore case
|
||||||
possible_values: [test123, test321]
|
possible_values: [test123, test321]
|
||||||
case_insensitive: true
|
ignore_case: true
|
||||||
- value_hint:
|
- value_hint:
|
||||||
long: value-hint
|
long: value-hint
|
||||||
help: Test value_hint
|
help: Test value_hint
|
||||||
|
|
|
@ -1058,7 +1058,7 @@ fn hide_single_possible_val() {
|
||||||
.long("pos")
|
.long("pos")
|
||||||
.value_name("VAL")
|
.value_name("VAL")
|
||||||
.possible_values(["fast", "slow"])
|
.possible_values(["fast", "slow"])
|
||||||
.possible_value(PossibleValue::new("secret speed").hidden(true))
|
.possible_value(PossibleValue::new("secret speed").hide(true))
|
||||||
.help("Some vals")
|
.help("Some vals")
|
||||||
.takes_value(true),
|
.takes_value(true),
|
||||||
)
|
)
|
||||||
|
@ -1162,13 +1162,13 @@ fn old_newline_chars() {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn issue_688_hidden_pos_vals() {
|
fn issue_688_hide_pos_vals() {
|
||||||
let filter_values = ["Nearest", "Linear", "Cubic", "Gaussian", "Lanczos3"];
|
let filter_values = ["Nearest", "Linear", "Cubic", "Gaussian", "Lanczos3"];
|
||||||
|
|
||||||
let app1 = App::new("ctest")
|
let app1 = App::new("ctest")
|
||||||
.version("0.1")
|
.version("0.1")
|
||||||
.term_width(120)
|
.term_width(120)
|
||||||
.setting(AppSettings::HidePossibleValuesInHelp)
|
.setting(AppSettings::HidePossibleValues)
|
||||||
.arg(Arg::new("filter")
|
.arg(Arg::new("filter")
|
||||||
.help("Sets the filter, or sampling method, to use for interpolation when resizing the particle \
|
.help("Sets the filter, or sampling method, to use for interpolation when resizing the particle \
|
||||||
images. The default is Linear (Bilinear). [possible values: Nearest, Linear, Cubic, Gaussian, Lanczos3]")
|
images. The default is Linear (Bilinear). [possible values: Nearest, Linear, Cubic, Gaussian, Lanczos3]")
|
||||||
|
@ -1382,12 +1382,12 @@ fn sc_negates_reqs() {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn hidden_args() {
|
fn hide_args() {
|
||||||
let app = App::new("prog")
|
let app = App::new("prog")
|
||||||
.version("1.0")
|
.version("1.0")
|
||||||
.arg(arg!(-f --flag "testing flags"))
|
.arg(arg!(-f --flag "testing flags"))
|
||||||
.arg(arg!(-o --opt <FILE> "tests options").required(false))
|
.arg(arg!(-o --opt <FILE> "tests options").required(false))
|
||||||
.arg(Arg::new("pos").hidden(true));
|
.arg(Arg::new("pos").hide(true));
|
||||||
assert!(utils::compare_output(
|
assert!(utils::compare_output(
|
||||||
app,
|
app,
|
||||||
"prog --help",
|
"prog --help",
|
||||||
|
@ -1414,7 +1414,7 @@ fn args_negate_sc() {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn issue_1046_hidden_scs() {
|
fn issue_1046_hide_scs() {
|
||||||
let app = App::new("prog")
|
let app = App::new("prog")
|
||||||
.version("1.0")
|
.version("1.0")
|
||||||
.arg(arg!(-f --flag "testing flags"))
|
.arg(arg!(-f --flag "testing flags"))
|
||||||
|
@ -1637,7 +1637,7 @@ fn last_arg_mult_usage_with_sc() {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn hidden_default_val() {
|
fn hide_default_val() {
|
||||||
let app1 = App::new("default").version("0.1").term_width(120).arg(
|
let app1 = App::new("default").version("0.1").term_width(120).arg(
|
||||||
Arg::new("argument")
|
Arg::new("argument")
|
||||||
.help("Pass an argument to the program. [default: default-argument]")
|
.help("Pass an argument to the program. [default: default-argument]")
|
||||||
|
@ -1897,7 +1897,7 @@ SPECIAL:
|
||||||
";
|
";
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn custom_help_headers_hidden_args() {
|
fn custom_help_headers_hide_args() {
|
||||||
let app = App::new("blorp")
|
let app = App::new("blorp")
|
||||||
.author("Will M.")
|
.author("Will M.")
|
||||||
.about("does stuff")
|
.about("does stuff")
|
||||||
|
@ -1908,7 +1908,7 @@ fn custom_help_headers_hidden_args() {
|
||||||
.short('n')
|
.short('n')
|
||||||
.long("no-proxy")
|
.long("no-proxy")
|
||||||
.help("Do not use system proxy settings")
|
.help("Do not use system proxy settings")
|
||||||
.hidden_short_help(true),
|
.hide_short_help(true),
|
||||||
)
|
)
|
||||||
.help_heading(Some("SPECIAL"))
|
.help_heading(Some("SPECIAL"))
|
||||||
.arg(
|
.arg(
|
||||||
|
@ -1925,7 +1925,7 @@ fn custom_help_headers_hidden_args() {
|
||||||
.long("server-addr")
|
.long("server-addr")
|
||||||
.help("Set server address")
|
.help("Set server address")
|
||||||
.help_heading(Some("NETWORKING"))
|
.help_heading(Some("NETWORKING"))
|
||||||
.hidden_short_help(true),
|
.hide_short_help(true),
|
||||||
);
|
);
|
||||||
|
|
||||||
assert!(utils::compare_output(
|
assert!(utils::compare_output(
|
||||||
|
@ -2003,7 +2003,7 @@ fn issue_1364_no_short_options() {
|
||||||
Arg::new("baz")
|
Arg::new("baz")
|
||||||
.short('z')
|
.short('z')
|
||||||
.value_name("BAZ")
|
.value_name("BAZ")
|
||||||
.hidden_short_help(true),
|
.hide_short_help(true),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::new("files")
|
Arg::new("files")
|
||||||
|
@ -2403,7 +2403,7 @@ fn only_custom_heading_opts_no_args() {
|
||||||
let app = App::new("test")
|
let app = App::new("test")
|
||||||
.version("1.4")
|
.version("1.4")
|
||||||
.setting(AppSettings::DisableVersionFlag)
|
.setting(AppSettings::DisableVersionFlag)
|
||||||
.mut_arg("help", |a| a.hidden(true))
|
.mut_arg("help", |a| a.hide(true))
|
||||||
.help_heading(Some("NETWORKING"))
|
.help_heading(Some("NETWORKING"))
|
||||||
.arg(arg!(-s --speed <SPEED> "How fast").required(false));
|
.arg(arg!(-s --speed <SPEED> "How fast").required(false));
|
||||||
|
|
||||||
|
@ -2429,7 +2429,7 @@ fn only_custom_heading_pos_no_args() {
|
||||||
let app = App::new("test")
|
let app = App::new("test")
|
||||||
.version("1.4")
|
.version("1.4")
|
||||||
.setting(AppSettings::DisableVersionFlag)
|
.setting(AppSettings::DisableVersionFlag)
|
||||||
.mut_arg("help", |a| a.hidden(true))
|
.mut_arg("help", |a| a.hide(true))
|
||||||
.help_heading(Some("NETWORKING"))
|
.help_heading(Some("NETWORKING"))
|
||||||
.arg(Arg::new("speed").help("How fast"));
|
.arg(Arg::new("speed").help("How fast"));
|
||||||
|
|
||||||
|
|
|
@ -19,16 +19,16 @@ OPTIONS:
|
||||||
";
|
";
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn hidden_args() {
|
fn hide_args() {
|
||||||
let app = App::new("test")
|
let app = App::new("test")
|
||||||
.author("Kevin K.")
|
.author("Kevin K.")
|
||||||
.about("tests stuff")
|
.about("tests stuff")
|
||||||
.version("1.4")
|
.version("1.4")
|
||||||
.args(&[
|
.args(&[
|
||||||
arg!(-f --flag "some flag").hidden(true),
|
arg!(-f --flag "some flag").hide(true),
|
||||||
arg!(-F --flag2 "some other flag"),
|
arg!(-F --flag2 "some other flag"),
|
||||||
arg!(--option <opt> "some option").required(false),
|
arg!(--option <opt> "some option").required(false),
|
||||||
Arg::new("DUMMY").hidden(true),
|
Arg::new("DUMMY").hide(true),
|
||||||
]);
|
]);
|
||||||
assert!(utils::compare_output(
|
assert!(utils::compare_output(
|
||||||
app,
|
app,
|
||||||
|
@ -76,9 +76,9 @@ OPTIONS:
|
||||||
Print version information
|
Print version information
|
||||||
";
|
";
|
||||||
|
|
||||||
/// Ensure hidden with short option
|
/// Ensure hide with short option
|
||||||
#[test]
|
#[test]
|
||||||
fn hidden_short_args() {
|
fn hide_short_args() {
|
||||||
let app = App::new("test")
|
let app = App::new("test")
|
||||||
.about("hides short args")
|
.about("hides short args")
|
||||||
.author("Steve P.")
|
.author("Steve P.")
|
||||||
|
@ -87,7 +87,7 @@ fn hidden_short_args() {
|
||||||
Arg::new("cfg")
|
Arg::new("cfg")
|
||||||
.short('c')
|
.short('c')
|
||||||
.long("config")
|
.long("config")
|
||||||
.hidden_short_help(true)
|
.hide_short_help(true)
|
||||||
.help("Some help text describing the --config arg"),
|
.help("Some help text describing the --config arg"),
|
||||||
Arg::new("visible")
|
Arg::new("visible")
|
||||||
.short('v')
|
.short('v')
|
||||||
|
@ -105,7 +105,7 @@ fn hidden_short_args() {
|
||||||
|
|
||||||
/// Ensure visible with opposite option
|
/// Ensure visible with opposite option
|
||||||
#[test]
|
#[test]
|
||||||
fn hidden_short_args_long_help() {
|
fn hide_short_args_long_help() {
|
||||||
let app = App::new("test")
|
let app = App::new("test")
|
||||||
.about("hides short args")
|
.about("hides short args")
|
||||||
.author("Steve P.")
|
.author("Steve P.")
|
||||||
|
@ -114,7 +114,7 @@ fn hidden_short_args_long_help() {
|
||||||
Arg::new("cfg")
|
Arg::new("cfg")
|
||||||
.short('c')
|
.short('c')
|
||||||
.long("config")
|
.long("config")
|
||||||
.hidden_short_help(true)
|
.hide_short_help(true)
|
||||||
.help("Some help text describing the --config arg"),
|
.help("Some help text describing the --config arg"),
|
||||||
Arg::new("visible")
|
Arg::new("visible")
|
||||||
.short('v')
|
.short('v')
|
||||||
|
@ -151,7 +151,7 @@ OPTIONS:
|
||||||
";
|
";
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn hidden_long_args() {
|
fn hide_long_args() {
|
||||||
let app = App::new("test")
|
let app = App::new("test")
|
||||||
.about("hides long args")
|
.about("hides long args")
|
||||||
.author("Steve P.")
|
.author("Steve P.")
|
||||||
|
@ -160,7 +160,7 @@ fn hidden_long_args() {
|
||||||
Arg::new("cfg")
|
Arg::new("cfg")
|
||||||
.short('c')
|
.short('c')
|
||||||
.long("config")
|
.long("config")
|
||||||
.hidden_long_help(true)
|
.hide_long_help(true)
|
||||||
.help("Some help text describing the --config arg"),
|
.help("Some help text describing the --config arg"),
|
||||||
Arg::new("visible")
|
Arg::new("visible")
|
||||||
.short('v')
|
.short('v')
|
||||||
|
@ -193,7 +193,7 @@ OPTIONS:
|
||||||
";
|
";
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn hidden_long_args_short_help() {
|
fn hide_long_args_short_help() {
|
||||||
let app = App::new("test")
|
let app = App::new("test")
|
||||||
.about("hides long args")
|
.about("hides long args")
|
||||||
.author("Steve P.")
|
.author("Steve P.")
|
||||||
|
@ -202,7 +202,7 @@ fn hidden_long_args_short_help() {
|
||||||
Arg::new("cfg")
|
Arg::new("cfg")
|
||||||
.short('c')
|
.short('c')
|
||||||
.long("config")
|
.long("config")
|
||||||
.hidden_long_help(true)
|
.hide_long_help(true)
|
||||||
.help("Some help text describing the --config arg"),
|
.help("Some help text describing the --config arg"),
|
||||||
Arg::new("visible")
|
Arg::new("visible")
|
||||||
.short('v')
|
.short('v')
|
||||||
|
@ -232,9 +232,9 @@ OPTIONS:
|
||||||
";
|
";
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn hidden_pos_args() {
|
fn hide_pos_args() {
|
||||||
let app = App::new("test").version("1.4").args(&[
|
let app = App::new("test").version("1.4").args(&[
|
||||||
Arg::new("pos").help("some pos").hidden(true),
|
Arg::new("pos").help("some pos").hide(true),
|
||||||
Arg::new("another").help("another pos"),
|
Arg::new("another").help("another pos"),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
@ -257,7 +257,7 @@ OPTIONS:
|
||||||
";
|
";
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn hidden_subcmds() {
|
fn hide_subcmds() {
|
||||||
let app = App::new("test")
|
let app = App::new("test")
|
||||||
.version("1.4")
|
.version("1.4")
|
||||||
.subcommand(App::new("sub").setting(AppSettings::Hidden));
|
.subcommand(App::new("sub").setting(AppSettings::Hidden));
|
||||||
|
@ -279,16 +279,16 @@ After help
|
||||||
";
|
";
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn hidden_opt_args_only() {
|
fn hide_opt_args_only() {
|
||||||
let app = App::new("test")
|
let app = App::new("test")
|
||||||
.version("1.4")
|
.version("1.4")
|
||||||
.after_help("After help")
|
.after_help("After help")
|
||||||
.mut_arg("help", |a| a.hidden(true))
|
.mut_arg("help", |a| a.hide(true))
|
||||||
.mut_arg("version", |a| a.hidden(true))
|
.mut_arg("version", |a| a.hide(true))
|
||||||
.arg(
|
.arg(
|
||||||
arg!(--option <opt> "some option")
|
arg!(--option <opt> "some option")
|
||||||
.required(false)
|
.required(false)
|
||||||
.hidden(true),
|
.hide(true),
|
||||||
);
|
);
|
||||||
|
|
||||||
assert!(utils::compare_output(
|
assert!(utils::compare_output(
|
||||||
|
@ -308,13 +308,13 @@ After help
|
||||||
";
|
";
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn hidden_pos_args_only() {
|
fn hide_pos_args_only() {
|
||||||
let app = App::new("test")
|
let app = App::new("test")
|
||||||
.version("1.4")
|
.version("1.4")
|
||||||
.after_help("After help")
|
.after_help("After help")
|
||||||
.mut_arg("help", |a| a.hidden(true))
|
.mut_arg("help", |a| a.hide(true))
|
||||||
.mut_arg("version", |a| a.hidden(true))
|
.mut_arg("version", |a| a.hide(true))
|
||||||
.args(&[Arg::new("pos").help("some pos").hidden(true)]);
|
.args(&[Arg::new("pos").help("some pos").hide(true)]);
|
||||||
|
|
||||||
assert!(utils::compare_output(
|
assert!(utils::compare_output(
|
||||||
app,
|
app,
|
||||||
|
@ -333,12 +333,12 @@ After help
|
||||||
";
|
";
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn hidden_subcmds_only() {
|
fn hide_subcmds_only() {
|
||||||
let app = App::new("test")
|
let app = App::new("test")
|
||||||
.version("1.4")
|
.version("1.4")
|
||||||
.after_help("After help")
|
.after_help("After help")
|
||||||
.mut_arg("help", |a| a.hidden(true))
|
.mut_arg("help", |a| a.hide(true))
|
||||||
.mut_arg("version", |a| a.hidden(true))
|
.mut_arg("version", |a| a.hide(true))
|
||||||
.subcommand(App::new("sub").setting(AppSettings::Hidden));
|
.subcommand(App::new("sub").setting(AppSettings::Hidden));
|
||||||
|
|
||||||
assert!(utils::compare_output(
|
assert!(utils::compare_output(
|
||||||
|
|
|
@ -65,7 +65,7 @@ fn possible_value_arg_value() {
|
||||||
.arg(
|
.arg(
|
||||||
Arg::new("arg_value").index(1).possible_value(
|
Arg::new("arg_value").index(1).possible_value(
|
||||||
PossibleValue::new("test123")
|
PossibleValue::new("test123")
|
||||||
.hidden(false)
|
.hide(false)
|
||||||
.help("It's just a test"),
|
.help("It's just a test"),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
@ -243,7 +243,7 @@ fn possible_values_hidden_output() {
|
||||||
.short('O')
|
.short('O')
|
||||||
.possible_values(["slow", "fast"])
|
.possible_values(["slow", "fast"])
|
||||||
.possible_value(PossibleValue::new("ludicrous speed"))
|
.possible_value(PossibleValue::new("ludicrous speed"))
|
||||||
.possible_value(PossibleValue::new("forbidden speed").hidden(true))
|
.possible_value(PossibleValue::new("forbidden speed").hide(true))
|
||||||
),
|
),
|
||||||
"clap-test -O slo",
|
"clap-test -O slo",
|
||||||
PV_ERROR,
|
PV_ERROR,
|
||||||
|
@ -275,7 +275,7 @@ fn alias() {
|
||||||
.takes_value(true)
|
.takes_value(true)
|
||||||
.possible_value(PossibleValue::new("test123").alias("123"))
|
.possible_value(PossibleValue::new("test123").alias("123"))
|
||||||
.possible_value("test321")
|
.possible_value("test321")
|
||||||
.case_insensitive(true),
|
.ignore_case(true),
|
||||||
)
|
)
|
||||||
.try_get_matches_from(vec!["pv", "--option", "123"]);
|
.try_get_matches_from(vec!["pv", "--option", "123"]);
|
||||||
|
|
||||||
|
@ -293,7 +293,7 @@ fn aliases() {
|
||||||
.takes_value(true)
|
.takes_value(true)
|
||||||
.possible_value(PossibleValue::new("test123").aliases(["1", "2", "3"]))
|
.possible_value(PossibleValue::new("test123").aliases(["1", "2", "3"]))
|
||||||
.possible_value("test321")
|
.possible_value("test321")
|
||||||
.case_insensitive(true),
|
.ignore_case(true),
|
||||||
)
|
)
|
||||||
.try_get_matches_from(vec!["pv", "--option", "2"]);
|
.try_get_matches_from(vec!["pv", "--option", "2"]);
|
||||||
|
|
||||||
|
@ -302,7 +302,7 @@ fn aliases() {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn case_insensitive() {
|
fn ignore_case() {
|
||||||
let m = App::new("pv")
|
let m = App::new("pv")
|
||||||
.arg(
|
.arg(
|
||||||
Arg::new("option")
|
Arg::new("option")
|
||||||
|
@ -311,7 +311,7 @@ fn case_insensitive() {
|
||||||
.takes_value(true)
|
.takes_value(true)
|
||||||
.possible_value("test123")
|
.possible_value("test123")
|
||||||
.possible_value("test321")
|
.possible_value("test321")
|
||||||
.case_insensitive(true),
|
.ignore_case(true),
|
||||||
)
|
)
|
||||||
.try_get_matches_from(vec!["pv", "--option", "TeSt123"]);
|
.try_get_matches_from(vec!["pv", "--option", "TeSt123"]);
|
||||||
|
|
||||||
|
@ -324,7 +324,7 @@ fn case_insensitive() {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn case_insensitive_fail() {
|
fn ignore_case_fail() {
|
||||||
let m = App::new("pv")
|
let m = App::new("pv")
|
||||||
.arg(
|
.arg(
|
||||||
Arg::new("option")
|
Arg::new("option")
|
||||||
|
@ -341,7 +341,7 @@ fn case_insensitive_fail() {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn case_insensitive_multiple() {
|
fn ignore_case_multiple() {
|
||||||
let m = App::new("pv")
|
let m = App::new("pv")
|
||||||
.arg(
|
.arg(
|
||||||
Arg::new("option")
|
Arg::new("option")
|
||||||
|
@ -351,7 +351,7 @@ fn case_insensitive_multiple() {
|
||||||
.possible_value("test123")
|
.possible_value("test123")
|
||||||
.possible_value("test321")
|
.possible_value("test321")
|
||||||
.multiple_values(true)
|
.multiple_values(true)
|
||||||
.case_insensitive(true),
|
.ignore_case(true),
|
||||||
)
|
)
|
||||||
.try_get_matches_from(vec!["pv", "--option", "TeSt123", "teST123", "tESt321"]);
|
.try_get_matches_from(vec!["pv", "--option", "TeSt123", "teST123", "tESt321"]);
|
||||||
|
|
||||||
|
@ -363,7 +363,7 @@ fn case_insensitive_multiple() {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn case_insensitive_multiple_fail() {
|
fn ignore_case_multiple_fail() {
|
||||||
let m = App::new("pv")
|
let m = App::new("pv")
|
||||||
.arg(
|
.arg(
|
||||||
Arg::new("option")
|
Arg::new("option")
|
||||||
|
|
|
@ -543,7 +543,7 @@ fn required_if_val_present_fail() {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn required_if_val_present_case_insensitive_pass() {
|
fn required_if_val_present_ignore_case_pass() {
|
||||||
let res = App::new("ri")
|
let res = App::new("ri")
|
||||||
.arg(
|
.arg(
|
||||||
Arg::new("cfg")
|
Arg::new("cfg")
|
||||||
|
@ -555,7 +555,7 @@ fn required_if_val_present_case_insensitive_pass() {
|
||||||
Arg::new("extra")
|
Arg::new("extra")
|
||||||
.takes_value(true)
|
.takes_value(true)
|
||||||
.long("extra")
|
.long("extra")
|
||||||
.case_insensitive(true),
|
.ignore_case(true),
|
||||||
)
|
)
|
||||||
.try_get_matches_from(vec!["ri", "--extra", "vaL", "--config", "my.cfg"]);
|
.try_get_matches_from(vec!["ri", "--extra", "vaL", "--config", "my.cfg"]);
|
||||||
|
|
||||||
|
@ -563,7 +563,7 @@ fn required_if_val_present_case_insensitive_pass() {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn required_if_val_present_case_insensitive_fail() {
|
fn required_if_val_present_ignore_case_fail() {
|
||||||
let res = App::new("ri")
|
let res = App::new("ri")
|
||||||
.arg(
|
.arg(
|
||||||
Arg::new("cfg")
|
Arg::new("cfg")
|
||||||
|
@ -575,7 +575,7 @@ fn required_if_val_present_case_insensitive_fail() {
|
||||||
Arg::new("extra")
|
Arg::new("extra")
|
||||||
.takes_value(true)
|
.takes_value(true)
|
||||||
.long("extra")
|
.long("extra")
|
||||||
.case_insensitive(true),
|
.ignore_case(true),
|
||||||
)
|
)
|
||||||
.try_get_matches_from(vec!["ri", "--extra", "vaL"]);
|
.try_get_matches_from(vec!["ri", "--extra", "vaL"]);
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#![cfg(feature = "unicode")]
|
#![cfg(feature = "unicode")]
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn possible_values_case_insensitive() {
|
fn possible_values_ignore_case() {
|
||||||
let m = clap::App::new("pv")
|
let m = clap::App::new("pv")
|
||||||
.arg(
|
.arg(
|
||||||
clap::Arg::new("option")
|
clap::Arg::new("option")
|
||||||
|
@ -9,7 +9,7 @@ fn possible_values_case_insensitive() {
|
||||||
.long("--option")
|
.long("--option")
|
||||||
.takes_value(true)
|
.takes_value(true)
|
||||||
.possible_value("ä")
|
.possible_value("ä")
|
||||||
.case_insensitive(true),
|
.ignore_case(true),
|
||||||
)
|
)
|
||||||
.try_get_matches_from(vec!["pv", "--option", "Ä"]);
|
.try_get_matches_from(vec!["pv", "--option", "Ä"]);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue