use bpaf::{short, Bpaf, Parser};
use std::path::PathBuf;
#[derive(Debug, Clone, Bpaf)]
#[bpaf(options, version)]
#[allow(dead_code)]
struct Opts {
#[bpaf(short, long)]
debug: bool,
#[bpaf(external(verbose))]
verbose: usize,
#[bpaf(argument("SPEED"), fallback(42.0))]
speed: f64,
output: PathBuf,
#[bpaf(guard(positive, "must be positive"), fallback(1))]
nb_cars: u32,
files_to_process: Vec<PathBuf>,
}
fn verbose() -> impl Parser<usize> {
short('v')
.long("verbose")
.help("Increase the verbosity\nYou can specify it up to 3 times\neither as -v -v -v or as -vvv")
.req_flag(())
.many()
.map(|xs| xs.len())
.guard(|&x| x <= 3, "It doesn't get any more verbose than this")
}
fn positive(input: &u32) -> bool {
*input > 0
}
fn main() {
println!("{:#?}", opts().run());
}