Struct pretty_exec::clap::PossibleValue
[−]pub struct PossibleValue<'help> { /* private fields */ }Expand description
A possible value of an argument.
This is used for specifying possible values of Args.
NOTE: This struct is likely not needed for most usecases as it is only required to hide single values from help messages and shell completions or to attach help to possible values.
Examples
let cfg = Arg::new("config")
.takes_value(true)
.value_name("FILE")
.value_parser([
PossibleValue::new("fast"),
PossibleValue::new("slow").help("slower than fast"),
PossibleValue::new("secret speed").hide(true)
]);Implementations
impl<'help> PossibleValue<'help>
impl<'help> PossibleValue<'help>
pub fn new(name: &'help str) -> PossibleValue<'help>
pub fn new(name: &'help str) -> PossibleValue<'help>
Create a PossibleValue with 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
PossibleValue::new("fast")pub fn help(self, help: &'help str) -> PossibleValue<'help>
pub fn help(self, help: &'help str) -> PossibleValue<'help>
Sets the help description of the value.
This is typically displayed in completions (where supported) and should be a short, one-line description.
Examples
PossibleValue::new("slow")
.help("not fast")pub fn hide(self, yes: bool) -> PossibleValue<'help>
pub fn hide(self, yes: bool) -> PossibleValue<'help>
Hides 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
PossibleValue::new("secret")
.hide(true)pub fn alias(self, name: &'help str) -> PossibleValue<'help>
pub fn alias(self, name: &'help str) -> PossibleValue<'help>
pub fn aliases<I>(self, names: I) -> PossibleValue<'help> where
I: IntoIterator<Item = &'help str>,
pub fn aliases<I>(self, names: I) -> PossibleValue<'help> where
I: IntoIterator<Item = &'help str>,
Sets multiple hidden aliases for this argument value.
Examples
PossibleValue::new("slow")
.aliases(["not-fast", "snake-like"])impl<'help> PossibleValue<'help>
impl<'help> PossibleValue<'help>
Reflection
Deprecated, replaced with PossibleValue::is_hide_set
pub fn is_hide_set(&self) -> bool
pub fn is_hide_set(&self) -> bool
Report if PossibleValue::hide is set
pub fn get_visible_name(&self) -> Option<&'help str>
pub fn get_visible_name(&self) -> Option<&'help str>
Get the name if argument value is not hidden, None otherwise
pub fn get_name_and_aliases(&self) -> impl Iterator<Item = &'help str>
pub fn get_name_and_aliases(&self) -> impl Iterator<Item = &'help str>
Returns all valid values of the argument value.
Namely the name and all aliases.
pub fn matches(&self, value: &str, ignore_case: bool) -> bool
pub fn matches(&self, value: &str, ignore_case: bool) -> bool
Tests 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
let arg_value = PossibleValue::new("fast").alias("not-slow");
assert!(arg_value.matches("fast", false));
assert!(arg_value.matches("not-slow", false));
assert!(arg_value.matches("FAST", true));
assert!(!arg_value.matches("FAST", false));Trait Implementations
impl<'help> Clone for PossibleValue<'help>
impl<'help> Clone for PossibleValue<'help>
fn clone(&self) -> PossibleValue<'help>
fn clone(&self) -> PossibleValue<'help>
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source. Read more
impl<'help> Debug for PossibleValue<'help>
impl<'help> Debug for PossibleValue<'help>
impl<'help> Default for PossibleValue<'help>
impl<'help> Default for PossibleValue<'help>
fn default() -> PossibleValue<'help>
fn default() -> PossibleValue<'help>
Returns the “default value” for a type. Read more
impl<'help> From<&'help &'help str> for PossibleValue<'help>
impl<'help> From<&'help &'help str> for PossibleValue<'help>
fn from(s: &'help &'help str) -> PossibleValue<'help>
fn from(s: &'help &'help str) -> PossibleValue<'help>
Converts to this type from the input type.
impl<'help> From<&'help str> for PossibleValue<'help>
impl<'help> From<&'help str> for PossibleValue<'help>
fn from(s: &'help str) -> PossibleValue<'help>
fn from(s: &'help str) -> PossibleValue<'help>
Converts to this type from the input type.
impl<'help> PartialEq<PossibleValue<'help>> for PossibleValue<'help>
impl<'help> PartialEq<PossibleValue<'help>> for PossibleValue<'help>
fn eq(&self, other: &PossibleValue<'help>) -> bool
fn eq(&self, other: &PossibleValue<'help>) -> bool
This method tests for self and other values to be equal, and is used
by ==. Read more
fn ne(&self, other: &PossibleValue<'help>) -> bool
fn ne(&self, other: &PossibleValue<'help>) -> bool
This method tests for !=.
impl<'help> Eq for PossibleValue<'help>
impl<'help> StructuralEq for PossibleValue<'help>
impl<'help> StructuralPartialEq for PossibleValue<'help>
Auto Trait Implementations
impl<'help> RefUnwindSafe for PossibleValue<'help>
impl<'help> Send for PossibleValue<'help>
impl<'help> Sync for PossibleValue<'help>
impl<'help> Unpin for PossibleValue<'help>
impl<'help> UnwindSafe for PossibleValue<'help>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<Q, K> Equivalent<K> for Q where
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Q where
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
sourcefn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to key and return true if they are equal.
impl<X> Pipe for X
impl<X> Pipe for X
fn pipe<Return, Function>(self, f: Function) -> Return where
Function: FnOnce(Self) -> Return,
fn pipe<Return, Function>(self, f: Function) -> Return where
Function: FnOnce(Self) -> Return,
Apply f to self. Read more
fn pipe_ref<'a, Return, Function>(&'a self, f: Function) -> Return where
Function: FnOnce(&'a Self) -> Return,
fn pipe_ref<'a, Return, Function>(&'a self, f: Function) -> Return where
Function: FnOnce(&'a Self) -> Return,
Apply f to &self. Read more
fn pipe_mut<'a, Return, Function>(&'a mut self, f: Function) -> Return where
Function: FnOnce(&'a mut Self) -> Return,
fn pipe_mut<'a, Return, Function>(&'a mut self, f: Function) -> Return where
Function: FnOnce(&'a mut Self) -> Return,
Apply f to &mut self. Read more
fn pipe_as_ref<'a, Param, Return, Function>(&'a self, f: Function) -> Return where
Self: AsRef<Param>,
Param: 'a + ?Sized,
Function: FnOnce(&'a Param) -> Return,
fn pipe_as_ref<'a, Param, Return, Function>(&'a self, f: Function) -> Return where
Self: AsRef<Param>,
Param: 'a + ?Sized,
Function: FnOnce(&'a Param) -> Return,
Apply f to &self where f takes a single parameter of type Param
and Self implements trait AsRef<Param>. Read more
fn pipe_as_mut<'a, Param, Return, Function>(&'a mut self, f: Function) -> Return where
Self: AsMut<Param>,
Param: 'a + ?Sized,
Function: FnOnce(&'a mut Param) -> Return,
fn pipe_as_mut<'a, Param, Return, Function>(&'a mut self, f: Function) -> Return where
Self: AsMut<Param>,
Param: 'a + ?Sized,
Function: FnOnce(&'a mut Param) -> Return,
Apply f to &mut self where f takes a single parameter of type Param
and Self implements trait AsMut<Param>. Read more
fn pipe_deref<'a, Param, Return, Function>(&'a self, f: Function) -> Return where
Self: Deref<Target = Param>,
Param: 'a + ?Sized,
Function: FnOnce(&'a Param) -> Return,
fn pipe_deref<'a, Param, Return, Function>(&'a self, f: Function) -> Return where
Self: Deref<Target = Param>,
Param: 'a + ?Sized,
Function: FnOnce(&'a Param) -> Return,
Apply f to &self where f takes a single parameter of type Param
and Self implements trait Deref<Target = Param>. Read more
fn pipe_deref_mut<'a, Param, Return, Function>(
&'a mut self,
f: Function
) -> Return where
Self: DerefMut<Target = Param>,
Param: 'a + ?Sized,
Function: FnOnce(&'a mut Param) -> Return,
fn pipe_deref_mut<'a, Param, Return, Function>(
&'a mut self,
f: Function
) -> Return where
Self: DerefMut<Target = Param>,
Param: 'a + ?Sized,
Function: FnOnce(&'a mut Param) -> Return,
Apply f to &mut self where f takes a single parameter of type Param
and Self implements trait [DerefMut<Target = Param>]. Read more
fn pipe_borrow<'a, Param, Return, Function>(&'a self, f: Function) -> Return where
Self: Borrow<Param>,
Param: 'a + ?Sized,
Function: FnOnce(&'a Param) -> Return,
fn pipe_borrow<'a, Param, Return, Function>(&'a self, f: Function) -> Return where
Self: Borrow<Param>,
Param: 'a + ?Sized,
Function: FnOnce(&'a Param) -> Return,
Apply f to &self where f takes a single parameter of type Param
and Self implements trait Borrow<Param>. Read more
fn pipe_borrow_mut<'a, Param, Return, Function>(
&'a mut self,
f: Function
) -> Return where
Self: BorrowMut<Param>,
Param: 'a + ?Sized,
Function: FnOnce(&'a mut Param) -> Return,
fn pipe_borrow_mut<'a, Param, Return, Function>(
&'a mut self,
f: Function
) -> Return where
Self: BorrowMut<Param>,
Param: 'a + ?Sized,
Function: FnOnce(&'a mut Param) -> Return,
Apply f to &mut self where f takes a single parameter of type Param
and Self implements trait BorrowMut<Param>. Read more