Macro please_clap::clap_dispatch
[−]
[src]
macro_rules! clap_dispatch { ($matches:expr; { $( $name:ident $match_arm_args:tt => $callback:expr ),* }) => { ... }; (MATCH_ARM_ARGS, $matches:ident, ( $matches_name:pat, $($arg_name:ident as $varname:ident),* )) => { ... }; (MATCH_ARM_ARGS, $matches:ident, ( $matches_name:pat )) => { ... }; (MATCH_ARM_ARGS, $matches:ident, ()) => { ... }; }
Process a clap::ArgMatches
with pattern-matching-like syntax.
use self::clap::*; let matches = App::new("test") .subcommand(SubCommand::with_name("sub") .subcommand(SubCommand::with_name("subsub") .arg(Arg::with_name("TEST_ARG").index(1)))) .subcommand(SubCommand::with_name("othersub")) .get_matches_from(vec!["test", "sub", "subsub", "fooarg"]); let mut called = false; clap_dispatch!(matches; { sub(sub_matches) => clap_dispatch!(sub_matches; { subsub(_, TEST_ARG as test_arg) => { assert_eq!(test_arg, "fooarg"); called = true; } }), othersub() => { panic!("Should not have been called."); } }); assert!(called);