fix!: Remove forbid_empty_values

This commit is contained in:
Ed Page 2022-07-21 15:24:25 -05:00
parent 6e1e0f9fa2
commit 137924fe48
5 changed files with 1 additions and 55 deletions

View file

@ -1702,24 +1702,6 @@ impl<'help> Arg<'help> {
}
}
/// Deprecated, replaced with [`Arg::value_parser(NonEmptyStringValueParser::new())`]
#[inline]
#[must_use]
#[cfg_attr(
feature = "deprecated",
deprecated(
since = "3.2.0",
note = "Replaced with `Arg::value_parser(NonEmptyStringValueParser::new())`"
)
)]
pub fn forbid_empty_values(self, yes: bool) -> Self {
if yes {
self.setting(ArgSettings::ForbidEmptyValues)
} else {
self.unset_setting(ArgSettings::ForbidEmptyValues)
}
}
/// Requires that options use the `--option=val` syntax
///
/// i.e. an equals between the option and associated value.
@ -4455,15 +4437,6 @@ impl<'help> Arg<'help> {
self.is_set(ArgSettings::AllowHyphenValues)
}
/// Deprecated, replaced with [`Arg::get_value_parser()`]
#[cfg_attr(
feature = "deprecated",
deprecated(since = "3.2.0", note = "Replaced with `Arg::get_value_parser()`")
)]
pub fn is_forbid_empty_values_set(&self) -> bool {
self.is_set(ArgSettings::ForbidEmptyValues)
}
/// Deprecated, replaced with [`Arg::get_value_parser()`
#[cfg_attr(
feature = "deprecated",

View file

@ -54,15 +54,6 @@ pub enum ArgSettings {
deprecated(since = "3.1.0", note = "Replaced with `Arg::action` (Issue #3772)")
)]
MultipleOccurrences,
/// Deprecated, replaced with [`Arg::value_parser(NonEmptyStringValueParser::new())`]
#[cfg_attr(
feature = "deprecated",
deprecated(
since = "3.1.0",
note = "Replaced with `Arg::value_parser(NonEmptyStringValueParser::new())`"
)
)]
ForbidEmptyValues,
/// Deprecated, replaced with [`Arg::global`] and [`Arg::is_global_set`]
#[cfg_attr(
feature = "deprecated",
@ -237,7 +228,6 @@ bitflags! {
struct Flags: u32 {
const REQUIRED = 1;
const MULTIPLE_OCC = 1 << 1;
const NO_EMPTY_VALS = 1 << 2;
const GLOBAL = 1 << 3;
const HIDDEN = 1 << 4;
const TAKES_VAL = 1 << 5;
@ -269,7 +259,6 @@ impl_settings! { ArgSettings, ArgFlags,
Required => Flags::REQUIRED,
MultipleOccurrences => Flags::MULTIPLE_OCC,
MultipleValues => Flags::MULTIPLE_VALS,
ForbidEmptyValues => Flags::NO_EMPTY_VALS,
Global => Flags::GLOBAL,
Hidden => Flags::HIDDEN,
TakesValue => Flags::TAKES_VAL,

View file

@ -747,7 +747,6 @@ fn assert_arg_flags(arg: &Arg) {
checker!(is_ignore_case_set requires is_takes_value_set);
{
#![allow(deprecated)]
checker!(is_forbid_empty_values_set requires is_takes_value_set);
checker!(is_allow_invalid_utf8_set requires is_takes_value_set);
}
}

View file

@ -93,7 +93,7 @@ pub enum ErrorKind {
/// let res = Command::new("prog")
/// .arg(Arg::new("color")
/// .takes_value(true)
/// .forbid_empty_values(true)
/// .value_parser(clap::builder::NonEmptyStringValueParser::new())
/// .long("color"))
/// .try_get_matches_from(vec!["prog", "--color="]);
/// assert!(res.is_err());

View file

@ -114,21 +114,6 @@ impl<'help, 'cmd> Validator<'help, 'cmd> {
));
}
}
{
#![allow(deprecated)]
if arg.is_forbid_empty_values_set() && val.is_empty() {
debug!("Validator::validate_arg_values: illegal empty val found");
return Err(Error::empty_value(
self.cmd,
&get_possible_values(arg)
.iter()
.filter(|pv| !pv.is_hide_set())
.map(PossibleValue::get_name)
.collect::<Vec<_>>(),
arg.to_string(),
));
}
}
if let Some(ref vtor) = arg.validator {
debug!("Validator::validate_arg_values: checking validator...");