Skip to content

fix: do not suggest a hidden help command - #2552

Open
ruziba3vich wants to merge 1 commit into
urfave:mainfrom
ruziba3vich:fix-suggest-hidden-help
Open

ruziba3vich wants to merge 1 commit into
urfave:mainfrom
ruziba3vich:fix-suggest-hidden-help

Conversation

@ruziba3vich

Copy link
Copy Markdown

What type of PR is this?

  • bug

What this PR does / why we need it:

suggestCommand adds help and h to the names of every command it looks at:

for _, name := range append(command.Names(), helpName, helpAlias) {

When the help command is visible it is already in the command list, so the append changes nothing. When it is hidden (HideHelpCommand or HideHelp), the function can return a command that does not exist.

With PrefixMatchCommands this stops a real command from running:

cmd := &cli.Command{
	Name:                "app",
	PrefixMatchCommands: true,
	HideHelpCommand:     true,
	Commands:            []*cli.Command{{Name: "hello", Action: ...}},
}
cmd.Run(ctx, []string{"app", "hel"})
// No help topic for 'hel'

suggestCommand returns help for hel (and h for h), Command("help") finds nothing, and hello is not run.

  • suggestions.go: iterate over command.Names() only.
  • suggestions_test.go: one test for suggestCommand without a help command in the list, one for the PrefixMatchCommands + HideHelpCommand run.

suggestFlag already takes a hideHelp argument for the same reason.

Which issue(s) this PR fixes:

None, I did not find an existing issue for this.

Testing

Both new tests fail on main (expected: "hello", actual: "help") and pass with the change. go test ./... passes. I did not run make (no gfmrun installed); the change does not touch the public API.

Release Notes

Hidden help command is no longer suggested or prefix-matched in place of a real command.

🤖 Generated with Claude Code

@ruziba3vich
ruziba3vich requested a review from a team as a code owner November 19, 2026 19:44

This branch has not been deployed

No deployments
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

Successfully merging this pull request may close these issues.

1 participant