Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

subcommandsRepeatable = true vs HelpCommand #2123

Open
roxspring opened this issue Sep 28, 2023 · 3 comments
Open

subcommandsRepeatable = true vs HelpCommand #2123

roxspring opened this issue Sep 28, 2023 · 3 comments

Comments

@roxspring
Copy link

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

@roxspring roxspring changed the title subcommandsRepeatable = true vs help subcommandsRepeatable = true vs HelpCommand Sep 28, 2023
@remkop
Copy link
Owner

remkop commented Sep 28, 2023

That does look unexpected. Could well be a bug.
Thank you for raising this!

@roxspring
Copy link
Author

Opened #2126 demonstrating the problem in a unit test.

Any thoughts on the best route forwards? Options that I see:

  1. HelpCommand.commands parameter somehow gets marked as "greedy" so that it takes precedence over command parsing!?
  2. HelpCommand falls back to interrogating parent.getCommandSpec().subcommands() to find which subcommands need usage shown
    1. Presumably multiple subcommands could be found this way, but only one usage should be shown...
    2. Is there an obvious choice which subcommand's usage should be shown?
  3. Just strongly recommend using --help options rather than the help command.

@roxspring
Copy link
Author

Added a potential fix to #2126 using a custom IParameterPreprocessor to implement the greedy approach (1). Feedback welcome!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants