Struct easy_args::ArgSpec[][src]

pub struct ArgSpec { /* fields omitted */ }
Expand description

Specifies the valid arguments of the program and is used to parse the command-line arguments into an [Arg].

Implementations

Creates an ArgSpecBuilder that can be used to build the ArgSpec.

Example

use easy_args::ArgSpec;

let spec = ArgSpec::build()
    .boolean("arg1")
    .done()
    .unwrap();

Determines if an argument of a given name and ArgType exists within the ArgSpec.

Example

use easy_args::{arg_spec, ArgType};

let spec = arg_spec!(username: String);
if spec.has_arg("username", ArgType::String) {
    let args = spec.parse().unwrap();
    if let Some(username) = args.string("username") {
        // do something with username
    }
}

Parses the command-line arguments and Returns [Ok(Args)] if there were no parse errors and [Err(Error)] if otherwise.

Example

use easy_args::arg_spec;

let spec = arg_spec!(vsync: bool);
match spec.parse() {
    Ok(args) => {
        // do stuff with the arguments
    }
    Err(err) => eprintln!("{:?}", err),
}

Trait Implementations

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.