pacak / bpaf

Command line parser with applicative interface
337 stars 17 forks source link

Non-hidden command alias, similar to `long` but non-hidden #357

Closed tyrone-wu closed 4 months ago

tyrone-wu commented 4 months ago

Hi 👋 , awesome library! 🐱

Is there a way to specify non-char alias' for a command, similar to long but not hidden?

pacak commented 4 months ago

You want to visible long names for the same command? There's no direct way to implement it - my assumption is for command line interface you want one and only one way for users to specify whatever they want, but you can always make two commands that parse in the same thing with minimal code duplication:

fn command_body() -> OptionParser<Command> {
    // make parser for command body here
}

fn commands() -> impl Parser<Command> {
    let a = command_body().command("alpha");
    let b = command_body().command("beta");
    construct!([a, b])
}

If you use derive macro - command_body would be #[bpaf(options)], commands is a standalone function that you use with external.

I wonder, why do you want that?