pacak / bpaf

Command line parser with applicative interface
Apache License 2.0
340 stars 17 forks source link

Broken command aliases #278

Closed ysndr closed 1 year ago

ysndr commented 1 year ago

Command aliases fail to parse (or I'm using them wrong?):

fn main() {
    groups().run();
}

#[derive(Debug, Bpaf, Clone)]
enum Groups {
    #[bpaf(command("top"), long("top-alias"), short('t')]
    Command(),
}
✅ $ cargo run -- top
💢 $ cargo run -- top-alias 
Error: expected `COMMAND ...`, got `top-alias`. Pass `--help` for usage information
💢 $ cargo run -- t
Error: expected `COMMAND ...`, got `t`. Pass `--help` for usage information
pacak commented 1 year ago

Seems like a bug in the derive macro.

pacak commented 1 year ago

derive-alias should fix it. Do you want a new release?

ysndr commented 1 year ago

confirming that

fn main() {
    groups2().run();
}

fn groups2() -> impl bpaf::Parser<()> {
    let command = bpaf::pure(()).to_options().command("top").long("top-alias");
    bpaf::construct!(command)
}

works

ysndr commented 1 year ago

derive-alias should fix it. Do you want a new release?

yes seems to work, thanks! I can use the branch for now, a release would be preferable

pacak commented 1 year ago

Okay, will try to release later today.

pacak commented 1 year ago

0.9.5 is out