[][src]Macro ezcli::named_option

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

Named optional command line argument with associated value.

Functionally identical to option but accepts a [Name] to allow for more robust CLI naming options. If there is no provided value with the option, the created variable is None, otherwise it is equal to the value wrapped in Some.

use ezcli::{named_option, name::Name};

// accepts "--amazing-option"
// "my_option" is now an Option<String> of the value passed in
named_option!(my_option, Name::long("amazing-option"));

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

use ezcli::{named_option, name::Name};

let args = ["-b", "value"];

// accepts "--accepts-both" or "-b"
// "my_option" is now an Option<String> of the value passed in
named_option!(my_option, Name::new("accepts-both", "b"), args);