Function bpaf::positional_if
source · [−]pub fn positional_if<F>(
metavar: &'static str,
check: F
) -> Parser<Option<String>> where
F: Fn(&str) -> bool + 'static,
Expand description
Positional argument that can be encoded as String and will be taken only if check passes
let is_short = |s: &str| s.len() < 10;
// skip this positional argument unless it's less than 10 bytes long
let arg: Parser<Option<String>> = positional_if("INPUT", is_short);