[][src]Struct trivial_argument_parser::ArgumentList

pub struct ArgumentList {
    pub dangling_values: Vec<String>,
    pub arguments: Vec<Argument>,
}

Acumulates arguments into list which then can be fed to parse.

Examples

use trivial_argument_parser::*;
let mut args_list = ArgumentList::new();
args_list.append_arg(Argument::new(Some('d'), None, ArgType::Flag).unwrap());
args_list.append_arg(Argument::new(Some('p'), None, ArgType::Value).unwrap());
args_list.append_arg(Argument::new(Some('l'), Some("an-list"), ArgType::ValueList).unwrap());

Fields

dangling_values: Vec<String>arguments: Vec<Argument>

Implementations

impl ArgumentList[src]

pub fn new() -> ArgumentList[src]

Create ArgumentList with empty vector of arguments.

pub fn append_arg(&mut self, argument: Argument)[src]

Append argument to the end of the list.

pub fn append_dangling_value(&mut self, value: &str)[src]

Append dangling values (dangling values)

pub fn search_by_short_name(
    &mut self,
    name: char
) -> Result<&mut Argument, String>
[src]

Search arguments by short name

pub fn search_by_long_name(
    &mut self,
    name: &str
) -> Result<&mut Argument, String>
[src]

Search arguments by long name

pub fn parse_args(&mut self, input: Vec<String>) -> Result<(), String>[src]

Function that does all the parsing. You need to feed user input.

Examples

use trivial_argument_parser::*;

let mut args_list = ArgumentList::new();
args_list.append_arg(Argument::new(Some('d'), None, ArgType::Flag).unwrap());
args_list.append_arg(Argument::new(Some('p'), None, ArgType::Value).unwrap());
args_list.append_arg(Argument::new(Some('l'), Some("an-list"), ArgType::ValueList).unwrap());
args_list.parse_args(args_to_string_vector(std::env::args())).unwrap();

Trait Implementations

impl Debug for ArgumentList[src]

Auto Trait Implementations

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.