Skip to content

cli: add long help text and command registry#23

Merged
abraithwaite merged 1 commit intomainfrom
cli-long-help-and-registry
Apr 7, 2026
Merged

cli: add long help text and command registry#23
abraithwaite merged 1 commit intomainfrom
cli-long-help-and-registry

Conversation

@abraithwaite
Copy link
Copy Markdown
Member

Summary

  • Adds WithLong(text) CmdOption for multi-line help text shown in --help
  • Adds cli.Register() / cli.Registered() for self-registering commands from outside main (supports build tags)

Long Help Text

cli.Command("up", "Launch a forge pod", &UpCmd{},
    cli.WithLong(`Launch a new forge pod for the given branch.
The pod runs Claude Code in headless mode with the given prompt.`),
)

Short description still used in parent command listings. Long text shown in --help output.

Command Registry

// In a separate package, conditionally included via build tags:
//go:build debug
func init() {
    cli.Register(cli.Command("debug", "Debug tools", &DebugCmd{}))
}

// In main:
app.AddCommand(cli.Registered()...)

Test plan

  • Long help text appears in --help output
  • Short desc still used in parent listings
  • Register/Registered accumulates commands
  • Registered returns a copy

- WithLong(text) CmdOption sets long-form help text on commands and groups,
  displayed indented before the Usage section when --help is invoked
- Group() updated to accept ...any (same pattern as Command()) so CmdOptions
  like WithLong can be passed alongside child nodes
- Register(nodes...)/Registered() add a package-level command registry for
  init()-based optional command inclusion via build tags
- Extract printLongText helper (dedup) and parseNodeOpts helper (dedup)
@abraithwaite abraithwaite merged commit 6c66404 into main Apr 7, 2026
1 check passed
@abraithwaite abraithwaite deleted the cli-long-help-and-registry branch April 7, 2026 05:01
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