Struct PossibleValue
pub struct PossibleValue { /* private fields */ }
A possible value of an argument.
This is used for specifying possible values of Args.
See also [PossibleValuesParser][crate::builder::PossibleValuesParser]
NOTE: Most likely you can use strings, rather than PossibleValue as it is only required
to hide single values from help messages and shell completions or to attach help to
possible values.
Examples
# use clap_builder as clap;
# use ;
let cfg = new
.action
.value_name
.value_parser;
Implementations
impl PossibleValue
fn new(name: impl Into<Str>) -> SelfCreate a
PossibleValuewith its name.The name will be used to decide whether this value was provided by the user to an argument.
NOTE: In case it is not hidden it will also be shown in help messages for arguments that use it as a possible value and have not hidden them through
Arg::hide_possible_values(true).Examples
# use clap_builder as clap; # use PossibleValue; new # ;fn help(self, help: impl IntoResettable<StyledStr>) -> SelfSets the help description of the value.
This is typically displayed in completions (where supported) and should be a short, one-line description.
Examples
# use clap_builder as clap; # use PossibleValue; new .help # ;fn hide(self, yes: bool) -> SelfHides this value from help and shell completions.
This is an alternative to hiding through
Arg::hide_possible_values(true), if you only want to hide some values.Examples
# use clap_builder as clap; # use PossibleValue; new .hide # ;fn alias(self, name: impl IntoResettable<Str>) -> SelfSets a hidden alias for this argument value.
Examples
# use clap_builder as clap; # use PossibleValue; new .alias # ;fn aliases(self, names: impl IntoIterator<Item = impl Into<Str>>) -> SelfSets multiple hidden aliases for this argument value.
Examples
# use clap_builder as clap; # use PossibleValue; new .aliases # ;
impl PossibleValue
fn get_name(&self) -> &strGet the name of the argument value
fn get_help(&self) -> Option<&StyledStr>Get the help specified for this argument, if any
fn is_hide_set(&self) -> boolReport if
PossibleValue::hideis setfn get_name_and_aliases(&self) -> impl Iterator<Item = &str> + '_Returns all valid values of the argument value.
Namely the name and all aliases.
fn matches(&self, value: &str, ignore_case: bool) -> boolTests if the value is valid for this argument value
The value is valid if it is either the name or one of the aliases.
Examples
# use clap_builder as clap; # use PossibleValue; let arg_value = new.alias; assert!; assert!; assert!; assert!;
Trait Implementations
impl Clone for PossibleValue
fn clone(&self) -> PossibleValue
impl Debug for PossibleValue
fn fmt(&self, f: &mut Formatter<'_>) -> Result
impl Default for PossibleValue
fn default() -> PossibleValue
impl Eq for PossibleValue
impl PartialEq for PossibleValue
fn eq(&self, other: &PossibleValue) -> bool
impl StructuralPartialEq for PossibleValue
impl<S: Into<Str>> From<S> for PossibleValue
fn from(s: S) -> Self
Auto Trait Implementations
impl Freeze for PossibleValue
impl RefUnwindSafe for PossibleValue
impl Send for PossibleValue
impl Sync for PossibleValue
impl Unpin for PossibleValue
impl UnsafeUnpin for PossibleValue
impl UnwindSafe for PossibleValue
Blanket Implementations
impl<T> Any for PossibleValue
where
T: 'static + ?Sized,
fn type_id(&self) -> TypeId
impl<T> Borrow<T> for PossibleValue
where
T: ?Sized,
fn borrow(&self) -> &T
impl<T> BorrowMut<T> for PossibleValue
where
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
impl<T> CloneToUninit for PossibleValue
where
T: Clone,
unsafe fn clone_to_uninit(&self, dest: *mut u8)
impl<T> From<T> for PossibleValue
fn from(t: T) -> TReturns the argument unchanged.
impl<T> ToOwned for PossibleValue
where
T: Clone,
type Owned = T;fn to_owned(&self) -> Tfn clone_into(&self, target: &mut T)
impl<T, U> Into<U> for PossibleValue
where
U: From<T>,
fn into(self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom<U> for PossibleValue
where
U: Into<T>,
type Error = Infallible;fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
impl<T, U> TryInto<U> for PossibleValue
where
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error;fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>