go-flags icon indicating copy to clipboard operation
go-flags copied to clipboard

Ability to control ordering/grouping of commands in help text

Open vito opened this issue 10 years ago • 2 comments

My CLI has a few commands that I'd like to call out for easier discoverability, e.g. login should be listed first. Currently commands are ordered alphabetically, which is a sane default especially when the AddCommand flow is used (since the order is not well-defined with func init()).

Some way to influence the ordering, or even better, having a way to group commands together (similar to option groups) would be nice. For example, in large CLIs you'll often have a set of commands relevant to a particular object type.

vito avatar Oct 26 '15 23:10 vito

Here's an example that would be helped by this kind of thing:

https://github.com/concourse/fly/blob/20980dc/commands/fly.go

Note that there's semantic grouping in the struct itself (which I'd happily group further if the group struct tags applied), which gets lost in the help text.

vito avatar Oct 27 '15 00:10 vito

I think allowing to place commands in groups would work pretty well. This requires some reorganization, but should be doable.

jessevdk avatar Oct 27 '15 06:10 jessevdk