pub struct Values { /* private fields */ }
Expand description
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.
Implementations§
source§impl Values
impl Values
sourcepub fn new(
default_values: HashMap<String, Value, RandomState>,
values: HashMap<String, Value, RandomState>
) -> Values
pub fn new(
default_values: HashMap<String, Value, RandomState>,
values: HashMap<String, Value, RandomState>
) -> Values
Construct a new Values structure using the given default values, and the given values parsed from the program’s command-line flags.
sourcepub fn contains_key(&self, name: &str) -> bool
pub fn contains_key(&self, name: &str) -> bool
Returns whether or not there exists a Value
for the given flag.
sourcepub fn get(&self, name: &str) -> Vec<&str, Global>
pub fn get(&self, name: &str) -> Vec<&str, Global>
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).