[][src]Struct simple_arguments::Arguments

pub struct Arguments<'a> { /* fields omitted */ }

the main struct which is responsible for managing all argument parsing logic

Methods

impl<'a> Arguments<'a>[src]

pub fn new(name: Option<&str>) -> Self[src]

initialises a new Arguments struct. You can give it an optional executable name which will be used to create the usage String.

pub fn add<T, S>(&mut self, filler: T, name: S, description: &str) where
    T: Filler + 'a,
    S: ToString
[src]

adds a new argument to the struct. filler must implement filler (all &mut T where T: FromStr implement Filler)

pub fn parse<S: AsRef<str>>(
    &mut self,
    arguments: &[S]
) -> Result<Vec<String>, String>
[src]

fills every argument with the given arguments and returns a vector of all the arguments that weren't taken by any flag. If it fails, returns a string describing a parsing error or a lack of remaining arguments

pub fn usage(&self) -> String[src]

generates a usage string

pub fn add_bool<S: ToString>(
    &mut self,
    b: &'a mut bool,
    name: S,
    description: &str
)
[src]

since the default implementation of Filller for &mut bool would require the user tu write ./program --boolean-flag true instead of just ./program --boolean-flag, this functions adds a flag that, when given, will autmatically set the given variable to true

Auto Trait Implementations

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

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

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

impl<'a> Unpin for Arguments<'a>

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

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.