mirror of
https://github.com/clap-rs/clap
synced 2024-12-13 22:32:33 +00:00
fix!: Remove allow_invalid_utf8
This commit is contained in:
parent
0f3e1b17cf
commit
0405966896
4 changed files with 1 additions and 49 deletions
|
@ -1663,25 +1663,6 @@ impl<'help> Arg<'help> {
|
|||
}
|
||||
}
|
||||
|
||||
/// Deprecated, replaced with [`Arg::value_parser(...)`] with either [`ValueParser::os_string()`][crate::builder::ValueParser::os_string]
|
||||
/// or [`ValueParser::path_buf()`][crate::builder::ValueParser::path_buf]
|
||||
#[inline]
|
||||
#[must_use]
|
||||
#[cfg_attr(
|
||||
feature = "deprecated",
|
||||
deprecated(
|
||||
since = "3.2.0",
|
||||
note = "Replaced with `Arg::value_parser(...)` with either `ValueParser::os_string()` or `ValueParser::path_buf()`"
|
||||
)
|
||||
)]
|
||||
pub fn allow_invalid_utf8(self, yes: bool) -> Self {
|
||||
if yes {
|
||||
self.setting(ArgSettings::AllowInvalidUtf8)
|
||||
} else {
|
||||
self.unset_setting(ArgSettings::AllowInvalidUtf8)
|
||||
}
|
||||
}
|
||||
|
||||
/// Requires that options use the `--option=val` syntax
|
||||
///
|
||||
/// i.e. an equals between the option and associated value.
|
||||
|
@ -4417,15 +4398,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_allow_invalid_utf8_set(&self) -> bool {
|
||||
self.is_set(ArgSettings::AllowInvalidUtf8)
|
||||
}
|
||||
|
||||
/// Behavior when parsing the argument
|
||||
pub fn get_action(&self) -> &super::ArgAction {
|
||||
const DEFAULT: super::ArgAction = super::ArgAction::StoreValue;
|
||||
|
@ -4450,9 +4422,6 @@ impl<'help> Arg<'help> {
|
|||
pub fn get_value_parser(&self) -> &super::ValueParser {
|
||||
if let Some(value_parser) = self.value_parser.as_ref() {
|
||||
value_parser
|
||||
} else if self.is_allow_invalid_utf8_set() {
|
||||
static DEFAULT: super::ValueParser = super::ValueParser::os_string();
|
||||
&DEFAULT
|
||||
} else {
|
||||
static DEFAULT: super::ValueParser = super::ValueParser::string();
|
||||
&DEFAULT
|
||||
|
@ -4574,8 +4543,6 @@ impl<'help> Arg<'help> {
|
|||
if self.value_parser.is_none() {
|
||||
if let Some(default) = self.action.as_ref().and_then(|a| a.default_value_parser()) {
|
||||
self.value_parser = Some(default);
|
||||
} else if self.is_allow_invalid_utf8_set() {
|
||||
self.value_parser = Some(super::ValueParser::os_string());
|
||||
} else {
|
||||
self.value_parser = Some(super::ValueParser::string());
|
||||
}
|
||||
|
|
|
@ -204,15 +204,6 @@ pub enum ArgSettings {
|
|||
)
|
||||
)]
|
||||
HiddenLongHelp,
|
||||
/// Deprecated, replaced with [`Arg::allow_invalid_utf8`] and [`Arg::is_allow_invalid_utf8_set`]
|
||||
#[cfg_attr(
|
||||
feature = "deprecated",
|
||||
deprecated(
|
||||
since = "3.1.0",
|
||||
note = "Replaced with `Arg::allow_invalid_utf8` and `Arg::is_allow_invalid_utf8_set`"
|
||||
)
|
||||
)]
|
||||
AllowInvalidUtf8,
|
||||
/// Deprecated, replaced with [`Arg::exclusive`] and [`Arg::is_exclusive_set`]
|
||||
#[cfg_attr(
|
||||
feature = "deprecated",
|
||||
|
@ -249,7 +240,6 @@ bitflags! {
|
|||
const MULTIPLE = Self::MULTIPLE_OCC.bits | Self::MULTIPLE_VALS.bits;
|
||||
#[cfg(feature = "env")]
|
||||
const HIDE_ENV = 1 << 21;
|
||||
const UTF8_NONE = 1 << 22;
|
||||
const EXCLUSIVE = 1 << 23;
|
||||
const NO_OP = 0;
|
||||
}
|
||||
|
@ -277,6 +267,5 @@ impl_settings! { ArgSettings, ArgFlags,
|
|||
HideDefaultValue => Flags::HIDE_DEFAULT_VAL,
|
||||
HiddenShortHelp => Flags::HIDDEN_SHORT_H,
|
||||
HiddenLongHelp => Flags::HIDDEN_LONG_H,
|
||||
AllowInvalidUtf8 => Flags::UTF8_NONE,
|
||||
Exclusive => Flags::EXCLUSIVE
|
||||
}
|
||||
|
|
|
@ -745,10 +745,6 @@ fn assert_arg_flags(arg: &Arg) {
|
|||
checker!(is_hide_default_value_set requires is_takes_value_set);
|
||||
checker!(is_multiple_values_set requires is_takes_value_set);
|
||||
checker!(is_ignore_case_set requires is_takes_value_set);
|
||||
{
|
||||
#![allow(deprecated)]
|
||||
checker!(is_allow_invalid_utf8_set requires is_takes_value_set);
|
||||
}
|
||||
}
|
||||
|
||||
fn assert_defaults<'d>(
|
||||
|
|
|
@ -271,7 +271,7 @@ pub enum ErrorKind {
|
|||
/// Occurs when the user provides a value containing invalid UTF-8.
|
||||
///
|
||||
/// To allow arbitrary data
|
||||
/// - Set [`Arg::allow_invalid_utf8`] for argument values
|
||||
/// - Set [`Arg::value_parser(value_parser!(OsString))`] for argument values
|
||||
/// - Set [`Command::allow_invalid_utf8_for_external_subcommands`] for external-subcommand
|
||||
/// values
|
||||
///
|
||||
|
|
Loading…
Reference in a new issue