Repository navigation
fix: show help for the whole subcommand path given to help - #2520
Merged
Merged
Conversation
`app help foo bar` showed the help of foo and ignored bar. The help command and the help flag now follow the args down as long as they name subcommands, so it shows bar's help, like `app foo help bar`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What type of PR is this?
What this PR does / why we need it:
app help foo barshows the help offoo, not of its subcommandbar, and silently ignoresbar. The same goes forapp -h foo bar. Onlyapp foo help barreachesbar:helpCommandActiononly looked at the first arg. It now follows the args down as long as each one names a subcommand of the previous one, aliases included, and shows the help of the last match. An arg that isn't a subcommand stops the walk, soapp help cmd nopestill showscmd's help, as it does today.Which issue(s) this PR fixes:
None, found while checking help output for nested commands.
Testing
TestHelpCommand_NestedPathcovershelp cmd subcmd, an alias in the path,-h cmd subcmd, andhelp cmd nope. The first three fail onmain; the last passes before and after.make generate vet check-binary-sizeandmake v3diffpass, with no API change.go test -race ./...passes, as do the tests withurfave_cli_no_template,urfave_cli_no_docsandurfave_cli_no_suggest.The change and the test were written with Claude Code (AI).
Release Notes
🤖 Generated with Claude Code