Macro sarge::get_arg

source ·
macro_rules! get_arg {
    ( $parser:ident, short, $tag:expr ) => { ... };
    ( $parser:ident, long, $tag:expr ) => { ... };
    ( $parser:ident, both, $short:expr, $long:expr ) => { ... };
}
Expand description

Macro to ease getting arguments from a parser.

Example:

use sarge::{get_arg, Tag, ArgType, Argument, ArgumentParser};
 
let mut parser = ArgumentParser::new();
parser.add(Argument::new(Tag::Long("help".into()), ArgType::Flag));
 
// Equivalent to `parser.arg(Tag::Long("help".into())).expect("Failed to get argument");`
get_arg!(parser, long, "help").expect("Failed to get argument");