[][src]Struct flaggy::Values

pub struct Values { /* fields omitted */ }

Values is a structure which contains all of the parsed command-line flag values (or the default values for those flags). If parsing fails (including if some required flags weren't specified, for example), an error is returned.

This structure provides various accessor functions, to conveniently get at the flag values. These accessors tend to follow the pattern of assuming the caller is doing things correctly, and that the caller wants us to panic early if something goes wrong. If this is not the desired behavior, the Values::get accessor provides a safe API where the caller can do their own error handling.

Methods

impl Values[src]

pub fn new(
    default_values: HashMap<String, Value, RandomState>,
    values: HashMap<String, Value, RandomState>
) -> Values
[src]

Construct a new Values structure using the given default values, and the given values parsed from the program's command-line flags.

pub fn contains_key(&self, name: &str) -> bool[src]

Returns whether or not there exists a Value for the given flag.

pub fn get(&self, name: &str) -> Vec<&str>[src]

Return the Value(s) of a single flag, as strings. The returned vector might be empty (if there is no Value associated with the flag), or it might contain exactly one entry (in the case of named or boolean flags), or it might contain many entries (in the case of positional flags).

pub fn get_as<E, T>(&self, name: &str) -> Result<Vec<T>, E> where
    T: FromStr<Err = E>, 
[src]

Return the Value(s) of a single flag, parsed into the given type. This is a convenience wrapper around get.

Trait Implementations

impl FromIterator<(String, Value)> for Values[src]

impl Eq for Values[src]

impl From<HashMap<String, Value, RandomState>> for Values[src]

impl PartialEq<Values> for Values[src]

impl Debug for Values[src]

Auto Trait Implementations

impl Send for Values

impl Sync for Values

Blanket Implementations

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T> From for T[src]

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.