picocli
picocli copied to clipboard
subcommandsRepeatable = true vs HelpCommand
If I've understood correctly then it seems that @CommandLine(subcommandsRepeatable) breaks HelpCommand's ability to provide help for that command.
For example, given a tool with subcommandsRepeatable = true and a subcommand sub, then I'd expect tool help sub to provide the usage for the sub subcommand, but what I see is the usage for tool itself.
Is this expected to work already and I'm doing something wrong? Or does this seem like a bug?
(I'll aim to isolate an example together tomorrow, but thought it might be worth starting the conversation sooner...)
That does look unexpected. Could well be a bug. Thank you for raising this!
Opened #2126 demonstrating the problem in a unit test.
Any thoughts on the best route forwards? Options that I see:
HelpCommand.commandsparameter somehow gets marked as "greedy" so that it takes precedence over command parsing!?HelpCommandfalls back to interrogatingparent.getCommandSpec().subcommands()to find which subcommands need usage shown- Presumably multiple subcommands could be found this way, but only one usage should be shown...
- Is there an obvious choice which subcommand's usage should be shown?
- Just strongly recommend using
--helpoptions rather than thehelpcommand.
Added a potential fix to https://github.com/remkop/picocli/pull/2126 using a custom IParameterPreprocessor to implement the greedy approach (1). Feedback welcome!