[−][src]Macro clap::value_t_or_exit
Convenience macro getting a typed value T
where T
implements std::str::FromStr
or
exiting upon error, instead of returning a Result
type.
NOTE: This macro is for backwards compatibility sake. Prefer
value_t!(/* ... */).unwrap_or_else(|e| e.exit())
Examples
let matches = App::new("myapp") .arg_from_usage("[length] 'Set the length to use as a pos whole num, i.e. 20'") .get_matches(); let len = value_t_or_exit!(matches.value_of("length"), u32); let also_len = value_t_or_exit!(matches, "length", u32); println!("{} + 2: {}", len, len + 2);