pacak/bpaf

Custom Help Section for group with exclusively hidden subcommands

Opened this issue · 4 comments

ysndr commented

First off, I'm trying to create a Group with a compact listing of subcommands, e.g..

Usage: flox [[-v]... | -q] [--debug]... [COMMAND ...]

Some Group
  search         search packages in subscribed channels

Additional Commands. Use `prog COMMAND --help' for more info
  build, upgrade, import, export, config, subscribe, unsubscribe, 
  channels, history

Since changing the layout of subcommands in the doc does not seem to be possible, I ended up with this wonky solution, that adds a non hidden subcommand "" to force showing the group:

/// Additional Commands. Use `prog COMMAND --help' for more info
///
/// build, upgrade, import, export, config, subscribe, unsubscribe, 
/// channels, history
#[derive(Bpaf, Clone)]
enum AdditionalCommands {
    Documentation(
        #[bpaf(external(AdditionalCommands::documentation), command("")] AdditionalCommandsDocumentation,
    ),
    Push(#[bpaf(external(environment::import), hide)] Import),
    Pull(#[bpaf(external(environment::export), hide)] Export),
}

Is there a way to achieve that anyway else?

pacak commented

So the goal is to create an indented block of text ("Additional commands ...") that shows up as "COMMAND" in generated usage line but without actual commands listed below? I'd put this text into "header" section of OptionParser and use with_usage to add COMMAND into usage line.

ysndr commented

The actual goal is to list all "additional" commands. We want to show those commands exist without taking too much vertical space.

The indented bit was a copy paste error, it should just be a group header like Some Group

I can't seem to manipulate the listing of subcommands so i hid all subcommands.
However a group disappears completely if all subcommands are hidden, this the weird hack i have now, with a "" command that I kinda have to handle somehow.

The group is supposed to come last, which makes utilizing the command header kinda not viable either..

pacak commented

I'll see what I can do

The group is supposed to come last, which makes utilizing the command header kinda not viable either..

There's also footer :)

ysndr commented

There's also footer :)

That's past the option listing 🙃