bpaf icon indicating copy to clipboard operation
bpaf copied to clipboard

Custom Help Section for group with exclusively hidden subcommands

Open ysndr opened this issue 2 years ago • 5 comments

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?

ysndr avatar Aug 22 '23 19:08 ysndr

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.

pacak avatar Aug 22 '23 19:08 pacak

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..

ysndr avatar Aug 22 '23 20:08 ysndr

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 :)

pacak avatar Aug 22 '23 20:08 pacak

There's also footer :)

That's past the option listing 🙃

ysndr avatar Aug 22 '23 20:08 ysndr