Struct easy_args::spec::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::spec::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::spec::{ArgSpec, ArgType}; let spec = ArgSpec::build() .string("username") .done() .unwrap(); 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::spec::ArgSpec; let spec = ArgSpec::build() .boolean("vsync") .done() .unwrap(); match spec.parse() { Ok(args) => { // do stuff with the arguments } Err(err) => eprintln!("{:?}", err), }
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for ArgSpecimpl UnwindSafe for ArgSpec