Struct ming::Parser [−][src]
pub struct Parser { /* fields omitted */ }
Expand description
A parser for command line arguments.
Implementations
Get the next option or positional argument.
A return value of Ok(None)
means the command line has been exhausted.
Options that are not valid unicode are transformed with replacement
characters as by String::from_utf8_lossy
.
Errors
Error::UnexpectedValue
is returned if the last option had a
value that hasn’t been consumed, as in --option=value
.
It’s possible to continue parsing after an error (but this is rarely useful).
Get a value for an option.
This function should normally be called right after seeing an option
that expects a value, with positional arguments being collected
using next()
.
A value is collected even if it looks like an option
(i.e., starts with -
).
This method can alternatively be used to collect the remaining
arguments if you want to stop processing options. For more information,
see examples/posixly_correct.rs
.
Errors
An Error::MissingValue
is returned if the end of the command
line is reached.
The name of the command, as in the zeroth argument of the process.
This may be useful to include in help or error messages.
Returns None
if:
- The parser was not constructed by
Parser::from_env
- The name is not valid unicode
- The name was not supplied by the system
Using Option::unwrap_or
for a fallback value is recommended.
Create a parser from the environment using std::env::args_os
.
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for Parser
impl !UnwindSafe for Parser