Enum docopt::Value
[−]
[src]
pub enum Value { Switch(bool), Counted(u64), Plain(Option<String>), List(Vec<String>), }
A matched command line value.
The value can be a boolean, counted repetition, a plain string or a list of strings.
The various as_{bool,count,str,vec}
methods provide convenient access
to values without destructuring manually.
Variants
Switch | A boolean value from a flag that has no argument. The presence of a flag means |
Counted | The number of occurrences of a repeated flag. |
Plain | A positional or flag argument. This is |
List | A List of positional or flag arguments. This list may be empty when no arguments or flags are present. |
Methods
impl Value
fn as_bool(&self) -> bool
Returns the value as a bool.
Counted repetitions are false
if 0
and true
otherwise.
Plain strings are true
if present and false
otherwise.
Lists are true
if non-empty and false
otherwise.
fn as_count(&self) -> u64
Returns the value as a count of the number of times it occurred.
Booleans are 1
if true
and 0
otherwise.
Plain strings are 1
if present and 0
otherwise.
Lists correspond to its length.
fn as_str<'a>(&'a self) -> &'a str
Returns the value as a string.
All values return an empty string except for a non-empty plain string.
fn as_vec<'a>(&'a self) -> Vec<&'a str>
Returns the value as a list of strings.
Booleans, repetitions and empty strings correspond to an empty list.
Plain strings correspond to a list of length 1
.