Macro sarge::arg

source ·
macro_rules! arg {
    ( flag, short, $tag:expr ) => { ... };
    ( flag, long, $tag:expr ) => { ... };
    ( flag, both, $short:expr, $long:expr ) => { ... };
    ( int, short, $tag:expr ) => { ... };
    ( int, long, $tag:expr ) => { ... };
    ( int, both, $short:expr, $long:expr ) => { ... };
    ( str, short, $tag:expr ) => { ... };
    ( str, long, $tag:expr ) => { ... };
    ( str, both, $short:expr, $long:expr ) => { ... };
}
Expand description

Macro to ease argument creation.

Example:

use sarge::{arg, Tag, ArgType, Argument};
 
// equivalent to `Argument::new(Flag::Short('h'), ArgType::Flag);`
arg!(flag, short, 'h');
 
// equivalent to `Argument::new(Flag::Long("num".into()), ArgType::Integer);`
arg!(int, long, "num");
 
// equivalent to `Argument::new(Flag::Both('a', "bc".into()), ArgType::String);`
arg!(str, both, 'a', "bc");