Documentation ergonomics for enums:
When defining tuple enum variants the bpaf configuration (and doc comment) have to be set inside the tuple, on the tuple values. For single value tuples that's annoying and brakes consistency with zero arg variants I see how this is necessary with multiple tuple values but single valued tuples could be special cased to forward doc and bpaf config to the inner field for ergonomics. This would also allow to infer the name of the flag.
#[derive(Bpaf, Clone, Debug)]
enum Verbosity {
Verbose (
/// Verbose mode.
///
/// Invoke multiple times for increasing detail.
#[bpaf(short('v'), long("verbose"), switch, many, map(vec_len))]
usize,
),
/// Quiet mode
#[bpaf(short, long, default)]
Quiet,
}
on batteries:
I am aware of the verbosity flags contained in the batteries feature, this is just for demonstration
So you want to be able to write something like this instead?
#[derive(Bpaf, Clone, Debug)]
enum Verbosity {
/// Verbose mode.
///
/// Invoke multiple times for increasing detail.
#[bpaf(short, long, switch, many, map(vec_len))]
Verbose (usize),
/// Quiet mode
#[bpaf(short, long, default)]
Quiet,
}
I'll see what it takes to implement.
Yes. I see that it is necessary for multiple fields or record variants, but for single ones some kind of surgar would be nice.
Implemented this for enums, seems to work. Looking into doing the same for structs, this needs a bit more thinking... Will get back to this later.