Struct Parser

Source
pub struct Parser<'a> { /* private fields */ }
Expand description

The command line parser.

Implementations§

Source§

impl<'a> Parser<'a>

Source

pub fn new() -> Parser<'a>

Return a new parser.

Source

pub fn opt<T>(&mut self, var: T) -> &mut Opt<'a>
where T: 'a + CommandLineArgument,

Add and return an option.

  • var is the associated variable
Source

pub fn param<T>(&mut self, var: T) -> &mut Param<'a>
where T: 'a + CommandLineArgument,

Add and return a parameter.

  • var is the associated variable
Source

pub fn auto_shorts(&mut self, auto_shorts: bool)

Set whether short options should be generated automatically.

Source

pub fn stop_on(&mut self, stopon: &'a str)

Specify an additional stop string.

Source

pub fn command_name(&mut self, command_name: &'a str)

Set the command name.

Source

pub fn usage(&mut self, usage: &'a str)

Set the usage string.

Source

pub fn synopsis(&mut self, synopsis: &'a str)

Set the synopsis string.

Source

pub fn version(&mut self, version: &'a str)

Set the version string.

Source

pub fn help(&mut self, help: bool)

Add help option.

Source

pub fn parse<'b, I>(&mut self, args: I) -> Result<Vec<&'b str>, Error>
where I: IntoIterator<Item = &'b str>,

Parse vector of command line arguments.

Returns a vector of remaining (unparsed) arguments.

Source

pub fn write_usage(&self, output: &mut dyn Write) -> Result<(), Error>

Write the usage string to some output stream.

Trait Implementations§

Source§

impl<'a> Default for Parser<'a>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for Parser<'a>

§

impl<'a> !RefUnwindSafe for Parser<'a>

§

impl<'a> !Send for Parser<'a>

§

impl<'a> !Sync for Parser<'a>

§

impl<'a> Unpin for Parser<'a>

§

impl<'a> !UnwindSafe for Parser<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.