Skip to content

feat: add opt-in help-all command (ref #2362)#2370

Open
dpritchett wants to merge 2 commits intospf13:mainfrom
dpritchett:help-all-command
Open

feat: add opt-in help-all command (ref #2362)#2370
dpritchett wants to merge 2 commits intospf13:mainfrom
dpritchett:help-all-command

Conversation

@dpritchett
Copy link

Summary

Adds NewHelpAllCommand() — an opt-in command that prints every visible, runnable command with args and description in one pass. Same wiring pattern as completion:

rootCmd.AddCommand(cobra.NewHelpAllCommand())
  • One line per command, columns aligned
  • --verbose adds flag placeholders with type-aware formatting
  • ~160 lines, no new dependencies

Context in #2362 (see my comment). Gist with gh output (~200 commands).

Example (patched into a local clone of gh)

$ gh help-all
    gh api <endpoint>                                            # Make an authenticated GitHub API request
    gh issue create                                              # Create a new issue
    gh pr merge [<number> | <url> | <branch>]                    # Merge a pull request
    gh repo clone <repository> [<directory>] [-- <gitflags>...]  # Clone a repository locally
    gh run watch <run-id>                                        # Watch a run until it completes
    ...

Full gist with ~200 commands

What's here

  • helpall.go: factory, tree walker, formatter, renderer
  • helpall_test.go: 19 tests

Roadmap

  • Implementation + tests
  • Proof of concept against gh CLI
  • Maintainer feedback on design
  • Doc page in site/content/ if accepted
  • Final review
  • Land

Add NewHelpAllCommand() factory that prints every visible, runnable
command with args and description in one pass — the cobra equivalent
of `rake routes`. Supports --verbose to include flag placeholders.

Ref: spf13#2362
Comment on lines +152 to +156
func NewHelpAllCommand() *Command {
var verbose bool

cmd := &Command{
Use: "help-all",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if we go in that direction I would use something like

Suggested change
func NewHelpAllCommand() *Command {
var verbose bool
cmd := &Command{
Use: "help-all",
func NewHelpAllCommand(argName s) *Command {
var verbose bool
cmd := &Command{
Use: argName,

There is no need to fix the positional argument to be "help-all", some users may want to use "help" or whatever they want

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, thanks. I've added a godoc example showing that the name is customizable via .Use on the returned *Command (see 8902815). This matches how cobra's own completion command works internally (hardcoded default name, mutable after creation).

@CLAassistant
Copy link

CLAassistant commented Mar 20, 2026

CLA assistant check
All committers have signed the CLA.

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.

3 participants