Struct easy_args::args::Args [−][src]
pub struct Args { /* fields omitted */ }Expand description
Holds all the command-line arguments given by the user.
Each argument is contained within a HashMap that can be index by the
argument’s name.
Implementations
Determines if an argument of a given name was set by the user in the command-line.
Example
use easy_args::spec::ArgSpec; let args = ArgSpec::build() .uinteger("window-height") .parse() .unwrap(); if args.is_set("window-height") { // resize the window height }
Returns a reference to the boolean value that corresponds with the given argument name.
Example
use easy_args::spec::ArgSpec; let args = ArgSpec::build() .boolean("fullscreen") .parse() .unwrap(); if args.boolean("fullscreen") == Some(&true) { // go fullscreen }
Returns a reference to the i64 value that corresponds with the given argument name.
Example
use easy_args::spec::ArgSpec; let args = ArgSpec::build() .integer("leaves") .parse() .unwrap(); let num_leaves_in_pile = *args.integer("leaves").unwrap_or(&0);
Returns a reference to the u64 value that corresponds with the given argument name.
Example
use easy_args::spec::ArgSpec; let args = ArgSpec::build() .uinteger("size") .parse() .unwrap(); let size = *args.uinteger("size").unwrap_or(&0);
Returns a reference to the String value that corresponds with the given argument name.
Exmaple
use easy_args::spec::ArgSpec; let args = ArgSpec::build() .string("username") .parse() .unwrap(); let username = args.string("username").unwrap_or(&"Guest".to_string());
Returns a reference to the boolean slice that corresponds with the given argument name.
Example
use easy_args::spec::ArgSpec; let args = ArgSpec::build() .boolean_array(5, "flags") .parse() .unwrap(); if let Some(flags) = args.boolean_array("flags") { // do something with flags }
Returns a reference to the i64 slice that corresponds with the given argument name.
Example
use easy_args::spec::ArgSpec; let args = ArgSpec::build() .integer_array(3, "position") .parse() .unwrap(); if let Some([x, y, z]) = args.integer_array("position") { // do something with the position }
Returns a reference to the u64 slice that corresponds with the given argument name.
Example
use easy_args::spec::ArgSpec; let args = ArgSpec::build() .uinteger_array(2, "size") .parse() .unwrap(); if let Some([width, height]) = args.uinteger_array("size") { // do something with screen size }
Returns a reference to the String slice that corresponds with the given argument name.
Exmaple
use easy_args::spec::ArgSpec; let args = ArgSpec::build() .string_array(2, "login-details") .parse() .unwrap(); if let Some([username, password]) = args.string_array("login-details") { // do something with username and password }
A Vector of all strings passed as command-line arguments that weren’t
arguments of the [ArgSpec].
Example
use easy_args::spec::ArgSpec; let args = ArgSpec::build().parse().unwrap(); for arg in args.free_args() { println!("What the heck is this? '{}'.", arg); }
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Argsimpl UnwindSafe for Args