Trait parkour::prelude::Parse [−][src]
An extension trait of palex::Input
, the trait for types that can produce
tokens from a list of command-line arguments.
This trait provides several convenience methods for parsing different things.
Note that this trait is automatically implemented for all types that
implement Input
.
Required methods
fn parse_value<V: FromInputValue>(
&mut self,
context: &V::Context
) -> Result<V, Error>
[src]
&mut self,
context: &V::Context
) -> Result<V, Error>
Parse a value using the FromInputValue
trait.
fn parse_short_flag(&mut self, flag: &str) -> bool
[src]
Convenience function for parsing a flag with a single dash, like -h
or
-foo
. Returns true
if it succeeded.
fn parse_long_flag(&mut self, flag: &str) -> bool
[src]
Convenience function for parsing a flag with two dashes, like --h
or
--foo
. Returns true
if it succeeded.
fn parse_command(&mut self, command: &str) -> bool
[src]
Convenience function for parsing a (sub)command, i.e. an argument that
doesn't start with a dash. Returns true
if it succeeded.
Provided methods
fn parse<F: FromInput>(&mut self, context: &F::Context) -> Result<F, Error>
[src]
Parse something using the FromInput
trait
fn try_parse<F: FromInput>(
&mut self,
context: &F::Context
) -> Result<Option<F>, Error>
[src]
&mut self,
context: &F::Context
) -> Result<Option<F>, Error>
Parse something using the FromInput
trait, but convert
Error::no_value
to Option::None
. This is useful when you want to
bubble up all errors except for Error::no_value
:
if let Some(x) = input.try_parse(&Flag::Short("o").into())? { // do something with x }
fn try_parse_value<V: FromInputValue>(
&mut self,
context: &V::Context
) -> Result<Option<V>, Error>
[src]
&mut self,
context: &V::Context
) -> Result<Option<V>, Error>
Parse a value using the FromInputValue
trait, but convert
Error::no_value
to Option::None
. This is useful when you want to
bubble up all errors except for Error::no_value
:
if let Some(value) = input.try_parse_value(&Default::default())? { // do something with value }
fn expect_empty(&mut self) -> Result<(), Error>
[src]
Returns an error if the input is not yet empty.
Implementors
impl<I: Input> Parse for I
[src]
fn parse_value<V: FromInputValue>(
&mut self,
context: &V::Context
) -> Result<V, Error>
[src]
&mut self,
context: &V::Context
) -> Result<V, Error>