Categories as slice, not a map anymore, order is always preserved
This commit is contained in:
8
app.go
8
app.go
@@ -6,6 +6,7 @@ import (
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path"
|
||||
"sort"
|
||||
"time"
|
||||
)
|
||||
|
||||
@@ -37,7 +38,7 @@ type App struct {
|
||||
// Display commands by category
|
||||
CategorizedHelp bool
|
||||
// Populate when displaying AppHelp
|
||||
Categories map[string]Commands
|
||||
Categories CommandCategories
|
||||
// An action to execute when the bash-completion flag is set
|
||||
BashComplete func(context *Context)
|
||||
// An action to execute before any subcommands are run, but after the context is ready
|
||||
@@ -100,11 +101,12 @@ func (a *App) Run(arguments []string) (err error) {
|
||||
}
|
||||
|
||||
if a.CategorizedHelp {
|
||||
a.Categories = make(map[string]Commands)
|
||||
a.Categories = CommandCategories{}
|
||||
for _, command := range a.Commands {
|
||||
a.Categories[command.Category] = append(a.Categories[command.Category], command)
|
||||
a.Categories = a.Categories.AddCommand(command.Category, command)
|
||||
}
|
||||
}
|
||||
sort.Sort(a.Categories)
|
||||
|
||||
newCmds := []Command{}
|
||||
for _, c := range a.Commands {
|
||||
|
Reference in New Issue
Block a user