A tool I am currently working on has a lot of subcommands which makes picocli's help output unclear. My code looks like this:
@Command(name = "toolName",
version = "version",
sortOptions = false,
parameterListHeading = "%nParameters:%n",
optionListHeading = "%nOptions:%n",
commandListHeading = "%nThese are common commands:%n%n",
subcommands = {
command1.class,
command2.class,
command3.class,
etc.class }
With help as:
@Option(names = {"-h", "--help"}, scope = ScopeType.INHERIT, usageHelp = true,
description = "Display this help message.")
boolean usageHelpRequested;
I want the help output to look similar to git's:
Here subcommands are divided into different functionalities (like start a working area) with a description. Is this possible using picocli?
Yes that is possible by diving under the hood of picocli's Help API.
One idea is to have a custom IHelpSectionRenderer
, see this example: https://github.com/remkop/picocli/blob/main/picocli-examples/src/main/java/picocli/examples/customhelp/GroupingDemo.java