Macro clap::clap_app[][src]

macro_rules! clap_app {
    (@app ($builder:expr)) => { ... };
    (@app ($builder:expr) (@arg ($name:expr): $($tail:tt)*) $($tt:tt)*) => { ... };
    (@app ($builder:expr) (@arg $name:ident: $($tail:tt)*) $($tt:tt)*) => { ... };
    (@app ($builder:expr) (@setting $setting:ident) $($tt:tt)*) => { ... };
    (@app ($builder:expr) (@attributes $($attr:tt)*) $($tt:tt)*) => { ... };
    (@app ($builder:expr) (@group $name:ident => $($tail:tt)*) $($tt:tt)*) => { ... };
    (@app ($builder:expr) (@group $name:ident !$ident:ident => $($tail:tt)*) $($tt:tt)*) => { ... };
    (@app ($builder:expr) (@group $name:ident +$ident:ident => $($tail:tt)*) $($tt:tt)*) => { ... };
    (@app ($builder:expr) (@subcommand $name:ident => $($tail:tt)*) $($tt:tt)*) => { ... };
    (@app ($builder:expr) ($ident:ident: $($v:expr),*) $($tt:tt)*) => { ... };
    (@group ($builder:expr, $group:expr)) => { ... };
    (@group ($builder:expr, $group:expr) (@attributes $($attr:tt)*) $($tt:tt)*) => { ... };
    (@group ($builder:expr, $group:expr) (@arg $name:ident: $($tail:tt)*) $($tt:tt)*) => { ... };
    (@arg ($arg:expr) $modes:tt) => { ... };
    (@arg ($arg:expr) $modes:tt --($long:expr) $($tail:tt)*) => { ... };
    (@arg ($arg:expr) $modes:tt --$long:ident $($tail:tt)*) => { ... };
    (@arg ($arg:expr) $modes:tt -$short:ident $($tail:tt)*) => { ... };
    (@arg ($arg:expr) (-) <$var:ident> $($tail:tt)*) => { ... };
    (@arg ($arg:expr) (+) <$var:ident> $($tail:tt)*) => { ... };
    (@arg ($arg:expr) (-) [$var:ident] $($tail:tt)*) => { ... };
    (@arg ($arg:expr) (+) [$var:ident] $($tail:tt)*) => { ... };
    (@arg ($arg:expr) $modes:tt ... $($tail:tt)*) => { ... };
    (@arg ($arg:expr) $modes:tt #{$n:expr, $m:expr} $($tail:tt)*) => { ... };
    (@arg ($arg:expr) $modes:tt * $($tail:tt)*) => { ... };
    (@arg ($arg:expr) $modes:tt !$ident:ident $($tail:tt)*) => { ... };
    (@arg ($arg:expr) $modes:tt +$ident:ident $($tail:tt)*) => { ... };
    (@arg ($arg:expr) $modes:tt {$fn_:expr} $($tail:tt)*) => { ... };
    (@as_expr $expr:expr) => { ... };
    (@arg ($arg:expr) $modes:tt $desc:tt) => { ... };
    (@arg ($arg:expr) $modes:tt $ident:ident[$($target:ident)*] $($tail:tt)*) => { ... };
    (@arg ($arg:expr) $modes:tt $ident:ident($($expr:expr),*) $($tail:tt)*) => { ... };
    (@arg ($arg:expr) $modes:tt $ident:ident($($expr:expr,)*) $($tail:tt)*) => { ... };
    (@subcommand $name:ident => $($tail:tt)*) => { ... };
    (($name:expr) => $($tail:tt)*) => { ... };
    ($name:ident => $($tail:tt)*) => { ... };
}

Build App, Args, SubCommands and Groups with Usage-string like input but without the associated parsing runtime cost.

clap_app! also supports several shorthand syntaxes.

Examples

let matches = clap_app!(myapp =>
    (version: "1.0")
    (author: "Kevin K. <kbknapp@gmail.com>")
    (about: "Does awesome things")
    (@arg CONFIG: -c --config +takes_value "Sets a custom config file")
    (@arg INPUT: +required "Sets the input file to use")
    (@arg debug: -d ... "Sets the level of debugging information")
    (@group difficulty =>
        (@arg hard: -h --hard "Sets hard mode")
        (@arg normal: -n --normal "Sets normal mode")
        (@arg easy: -e --easy "Sets easy mode")
    )
    (@subcommand test =>
        (about: "controls testing features")
        (version: "1.3")
        (author: "Someone E. <someone_else@other.com>")
        (@arg verbose: -v --verbose "Print test information verbosely")
    )
)
.get_matches();

Shorthand Syntax for Args

Shorthand Syntax for Groups