Struct clargs::Parser
[−]
[src]
pub struct Parser { /* fields omitted */ }
Object used to parse command-line arguments.
Holds information required to parse arguments and has methods to access this information.
Methods
impl Parser
[src]
fn new() -> Parser
[src]
Constructs and returns a new Parser
object.
fn is_valid_option_name(name: &str) -> bool
[src]
Returns true
if the specified name
is a valid option name.
An option's name can only contain lower and uppercase letters and hyphens.
fn has_option(&self, name: &str) -> bool
[src]
Returns true
if the Parser
currently has an option or an alias with the specified name
.
fn remove_option(&mut self, name: &str)
[src]
Invalidates any option with the specified name
from the Parser
object.
Does nothing if there is no such option.
If an option is removed, all aliases to that option will be removed aswell. If an alias is removed, only that alias will be removed and nothing else.
fn add_flag(&mut self, name: String) -> &mut Parser
[src]
Registers a new flag with the Parser
under the specified name
.
Panics
Panics if there already is an option or an alias with the specified name
.
Or if the specified name
is an invalid option name.
fn add_named_param<T: 'static + FromStr>(&mut self, name: String) -> &mut Parser
[src]
Registers a new named parameter with the Parser
under the specified name
.
The named parameter's associated type is set to the T
type.
Panics
Panics if there already is an option or an alias with the specified name
.
Or if the specified name
is an invalid option name.
fn add_alias(&mut self, name: String, target: String) -> &mut Parser
[src]
Registers a new alias with the Parser
with the specified name
to the specified target
.
Panics
Panics if there already is an option or an alias with the specified name
.
Or if the specified name
is an invalid option name.
Or if the specified target
is not a present option.
fn double_hyphen_marker(&self) -> bool
[src]
Returns true
if the double-hyphen marker is enabled.
fn enable_double_hyphen_marker(&mut self)
[src]
Enables the double-hyphen marker.
fn disable_double_hyphen_marker(&mut self)
[src]
Disables the double-hyphen marker.
fn match_options(&self, partial: &str) -> Vec<String>
[src]
Matches the specified partial
option name to the options registered with the Parser
.
A partial
matches an option if that option's name starts with partial
.
Matches are returned as a sorted vector of strings containing the options's names.
If an exact match occurs, only that option will be returned and all other matches are discarded.
fn resolve(&self, name: String) -> String
[src]
Returns the definite name of an option.
If the specified name
is an alias, returns the name of the option it points to.
Otherwise, returns the same string.
fn parse<I>(&self, args: I) -> Result<ParsingResults, ParsingError> where
I: Iterator,
I::Item: AsRef<str>,
[src]
I: Iterator,
I::Item: AsRef<str>,
Parses the specified command-line arguments.
If an error occurred according to the Parser
's configuration, a ParsingError
will be returned.
Otherwise, a ParsingResults
object will be returned containing the results.