Struct PossibleValue
struct PossibleValue { ... }
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<impl Into<Str>: Into<Str>>(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<impl IntoResettable<StyledStr>: IntoResettable<StyledStr>>(self: 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: 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<impl IntoResettable<Str>: IntoResettable<Str>>(self: 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<impl Into<Str>: Into<Str>, impl IntoIterator<Item = impl Into<Str>>: IntoIterator<Item = impl Into<Str>>>(self: 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: &Self) -> &strGet the name of the argument value
fn get_help(self: &Self) -> Option<&StyledStr>Get the help specified for this argument, if any
fn is_hide_set(self: &Self) -> boolReport if
PossibleValue::hideis setfn get_name_and_aliases(self: &Self) -> impl Iterator<Item = &str> + '_Returns all valid values of the argument value.
Namely the name and all aliases.
fn matches(self: &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!;
impl Clone for PossibleValue
fn clone(self: &Self) -> PossibleValue
impl Debug for PossibleValue
fn fmt(self: &Self, f: &mut Formatter<'_>) -> Result
impl Default for PossibleValue
fn default() -> PossibleValue
impl Eq for PossibleValue
impl Freeze for PossibleValue
impl PartialEq for PossibleValue
fn eq(self: &Self, other: &PossibleValue) -> bool
impl RefUnwindSafe for PossibleValue
impl Send for PossibleValue
impl StructuralPartialEq for PossibleValue
impl Sync for PossibleValue
impl Unpin for PossibleValue
impl UnsafeUnpin for PossibleValue
impl UnwindSafe for PossibleValue
impl<S: Into<crate::builder::Str>> From for PossibleValue
fn from(s: S) -> Self
impl<T> Any for PossibleValue
fn type_id(self: &Self) -> TypeId
impl<T> Borrow for PossibleValue
fn borrow(self: &Self) -> &T
impl<T> BorrowMut for PossibleValue
fn borrow_mut(self: &mut Self) -> &mut T
impl<T> CloneToUninit for PossibleValue
unsafe fn clone_to_uninit(self: &Self, dest: *mut u8)
impl<T> From for PossibleValue
fn from(t: T) -> TReturns the argument unchanged.
impl<T> ToOwned for PossibleValue
fn to_owned(self: &Self) -> Tfn clone_into(self: &Self, target: &mut T)
impl<T, U> Into for PossibleValue
fn into(self: Self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom for PossibleValue
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
impl<T, U> TryInto for PossibleValue
fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::Error>