pub struct UnknownArgumentValueParser { /* private fields */ }
Expand description
When encountered, report ErrorKind::UnknownArgument
Useful to help users migrate, either from old versions or similar tools.
§Examples
let cmd = Command::new("mycmd")
.args([
Arg::new("current-dir")
.short('C'),
Arg::new("current-dir-unknown")
.long("cwd")
.aliases(["current-dir", "directory", "working-directory", "root"])
.value_parser(clap::builder::UnknownArgumentValueParser::suggest_arg("-C"))
.hide(true),
]);
// Use a supported version of the argument
let matches = cmd.clone().try_get_matches_from(["mycmd", "-C", ".."]).unwrap();
assert!(matches.contains_id("current-dir"));
assert_eq!(
matches.get_many::<String>("current-dir").unwrap_or_default().map(|v| v.as_str()).collect::<Vec<_>>(),
vec![".."]
);
// Use one of the invalid versions
let err = cmd.try_get_matches_from(["mycmd", "--cwd", ".."]).unwrap_err();
assert_eq!(err.kind(), clap::error::ErrorKind::UnknownArgument);
Implementations§
Trait Implementations§
Source§impl Clone for UnknownArgumentValueParser
impl Clone for UnknownArgumentValueParser
Source§fn clone(&self) -> UnknownArgumentValueParser
fn clone(&self) -> UnknownArgumentValueParser
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for UnknownArgumentValueParser
impl Debug for UnknownArgumentValueParser
Source§impl TypedValueParser for UnknownArgumentValueParser
impl TypedValueParser for UnknownArgumentValueParser
Source§fn parse_ref(
&self,
cmd: &Command,
arg: Option<&Arg>,
value: &OsStr,
) -> Result<Self::Value, Error>
fn parse_ref( &self, cmd: &Command, arg: Option<&Arg>, value: &OsStr, ) -> Result<Self::Value, Error>
Parse the argument value Read more
Source§fn parse_ref_(
&self,
cmd: &Command,
arg: Option<&Arg>,
_value: &OsStr,
source: ValueSource,
) -> Result<Self::Value, Error>
fn parse_ref_( &self, cmd: &Command, arg: Option<&Arg>, _value: &OsStr, source: ValueSource, ) -> Result<Self::Value, Error>
Parse the argument value Read more
Source§fn parse(
&self,
cmd: &Command,
arg: Option<&Arg>,
value: OsString,
) -> Result<Self::Value, Error>
fn parse( &self, cmd: &Command, arg: Option<&Arg>, value: OsString, ) -> Result<Self::Value, Error>
Parse the argument value Read more
Source§fn parse_(
&self,
cmd: &Command,
arg: Option<&Arg>,
value: OsString,
_source: ValueSource,
) -> Result<Self::Value, Error>
fn parse_( &self, cmd: &Command, arg: Option<&Arg>, value: OsString, _source: ValueSource, ) -> Result<Self::Value, Error>
Parse the argument value Read more
Source§fn possible_values(
&self,
) -> Option<Box<dyn Iterator<Item = PossibleValue> + '_>>
fn possible_values( &self, ) -> Option<Box<dyn Iterator<Item = PossibleValue> + '_>>
Reflect on enumerated value properties Read more
Source§fn map<T, F>(self, func: F) -> MapValueParser<Self, F>
fn map<T, F>(self, func: F) -> MapValueParser<Self, F>
Adapt a
TypedValueParser
from one value to another Read moreAuto Trait Implementations§
impl Freeze for UnknownArgumentValueParser
impl RefUnwindSafe for UnknownArgumentValueParser
impl Send for UnknownArgumentValueParser
impl Sync for UnknownArgumentValueParser
impl Unpin for UnknownArgumentValueParser
impl UnwindSafe for UnknownArgumentValueParser
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<I> IntoResettable<ValueParser> for Iwhere
I: Into<ValueParser>,
impl<I> IntoResettable<ValueParser> for Iwhere
I: Into<ValueParser>,
Source§fn into_resettable(self) -> Resettable<ValueParser>
fn into_resettable(self) -> Resettable<ValueParser>
Convert to the intended resettable type