[][src]Macro ezcli::flag

macro_rules! flag {
    ($name:tt, $args:ident) => { ... };
    ($name:tt) => { ... };
}

Command line argument flag for on/off state.

Uses std::env:args() to determine the arguments passed to the program. If there is an argument matching the flag's name then this variable will be truthy.

use ezcli::flag;

// accepts "--my_boolean"
// if passed in, "my_boolean" is true
flag!(my_boolean);

In some case of not wanting to use the program's environment arguments using a slice is also possible.

use ezcli::flag;

let args = ["--my_boolean"];

// accepts "--my_boolean"
// if passed in, "my_boolean" is true
flag!(my_boolean, args);

If the command line argument name should be different to the variable name then use named_flag.