Struct argparse_rs::argparser::ArgParseResults [] [src]

pub struct ArgParseResults { /* fields omitted */ }

This type represents the result ofparsing arguments.

Methods

impl ArgParseResults
[src]

Extracts the argument, as long is the value type implements FromStr

Example

use argparse::{ArgParser, ArgType};

let mut parser = ArgParser::new("runner".into());
parser.add_opt("verbose", Some("false"), 'v', false,
    "Whether to produce verbose output", ArgType::Flag);

// Normally you'd get this from std::env::args().iter()
let test_1 = "./runner -v".split_whitespace()
    .map(|s| s.into())
    .collect::<Vec<String>>();
 
if let Ok(p_res) = parser.parse(test_1.iter()) {
    if let Some(true) = p_res.get::<bool>("verbose") {
        // be verbose
    }
}

Extracts the argument, using the ArgGetter<T> that you provided

Note

See documentation for the trait ArgGetter for more information

Example

use argparse::{ArgParser, ArgType};

let mut parser = ArgParser::new("runner".into());
parser.add_opt("verbose", Some("false"), 'v', false,
    "Whether to produce verbose output", ArgType::Flag);

// Normally you'd get this from std::env::args().iter()
let test_1 = "./runner -v".split_whitespace()
    .map(|s| s.into())
    .collect::<Vec<String>>();
 
let dumb_closure = |_: &str| { Some(true) };
 
if let Ok(p_res) = parser.parse(test_1.iter()) {
    if let Some(true) = p_res.get_with::<bool, _>("verbose", dumb_closure) {
        // be verbose
    }
}

Trait Implementations

impl Debug for ArgParseResults
[src]

Formats the value using the given formatter.

impl Clone for ArgParseResults
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more