Struct easy_args::ArgSpecBuilder[][src]

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

Builder type for ArgSpec.

Implementations

Completes building the ArgSpec. Returns [Ok(ArgSpec)] if no build errors and [Err(Error)] if otherwise.

Example

use easy_args::ArgSpec;

let spec = ArgSpec::build()
    .uinteger("chickens")
    .done().
    unwrap();

Little Wrapper function that will complete building the ArgSpec and immediately call [parse()].

Example

use easy_args::arg_spec;

let args = arg_spec! {
    fullscreen: bool,
    vsync: bool,
    username: String
}
.parse()
.unwrap();

Adds an argument the the ArgSpec with a given name and type.

Example

use easy_args::{ArgSpec, ArgType};

let spec = ArgSpec::build()
    .arg("flag", ArgType::Boolean)
    .done()
    .unwrap();

Adds a boolean argument to the ArgSpec.

Example

use easy_args::{ArgSpec, ArgType};

 let spec = ArgSpec::build()
    .boolean("vsync")
    .done()
    .unwrap();
 assert_eq!(spec.has_arg("vsync", ArgType::Boolean), true);

Adds an i64 argument to the ArgSpec.

Exmaple

use easy_args::{ArgSpec, ArgType};

let spec = ArgSpec::build()
    .integer("num-bananas")
    .done()
    .unwrap();
assert_eq!(spec.has_arg("num-bananas", ArgType::Integer), true);

Adds a u64 argument to the ArgSpec.

Exmaple

use easy_args::{ArgSpec, ArgType};

let spec = ArgSpec::build()
    .uinteger("screen-width")
    .done()
    .unwrap();
assert_eq!(spec.has_arg("screen-width", ArgType::UInteger), true);

Adds an f64 argument to the ArgSpec.

Exmaple

use easy_args::{ArgSpec, ArgType};

let spec = ArgSpec::build()
    .float("gravity")
    .done()
    .unwrap();
assert_eq!(spec.has_arg("gravity", ArgType::Float), true);

Adds a String argument to the ArgSpec.

Exmaple

use easy_args::{ArgSpec, ArgType};

let spec = ArgSpec::build()
    .string("MOTD")
    .done()
    .unwrap();
assert_eq!(spec.has_arg("MOTD", ArgType::String), true);

Adds a boolean array argument to the ArgSpec.

Example

use easy_args::{ArgSpec, ArgType};

 let spec = ArgSpec::build()
    .boolean_array(2, "bools")
    .done()
    .unwrap();
 assert_eq!(spec.has_arg("bools", ArgType::BooleanArray(2)), true);

Adds an i64 array argument to the ArgSpec.

Exmaple

use easy_args::{ArgSpec, ArgType};

let spec = ArgSpec::build()
    .integer_array(3, "position")
    .done()
    .unwrap();
assert_eq!(spec.has_arg("position", ArgType::IntegerArray(3)), true);

Adds a u64 array argument to the ArgSpec.

Exmaple

use easy_args::{ArgSpec, ArgType};

let spec = ArgSpec::build()
    .uinteger_array(2, "size")
    .done()
    .unwrap();
assert_eq!(spec.has_arg("size", ArgType::UIntegerArray(2)), true);

Adds a f64 array argument to the ArgSpec.

Exmaple

use easy_args::{ArgSpec, ArgType};

let spec = ArgSpec::build()
    .float_array(3, "position")
    .done()
    .unwrap();
assert_eq!(spec.has_arg("position", ArgType::FloatArray(2)), true);

Adds a String array argument to the ArgSpec.

Exmaple

use easy_args::{ArgSpec, ArgType};

let spec = ArgSpec::build()
    .string_array(2, "name")
    .done()
    .unwrap();
assert_eq!(spec.has_arg("name", ArgType::StringArray(2)), true);

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.