pub struct ArgSpecBuilder { /* fields omitted */ }
Expand description
Completes building the ArgSpec
. Returns [Ok(ArgSpec)
] if no build
errors and [Err(Error)
] if otherwise.
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()
].
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.
use easy_args::{ArgSpec, ArgType};
let spec = ArgSpec::build()
.arg("flag", ArgType::Boolean)
.done()
.unwrap();
Adds a boolean argument to the ArgSpec
.
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
.
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
.
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
.
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
.
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
.
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
.
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
.
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
.
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
.
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);
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
The type returned in the event of a conversion error.
The type returned in the event of a conversion error.