Make slice wrapping pattern more consistent

and move *Args out into its own file
This commit is contained in:
Dan Buch
2016-05-23 20:15:35 -04:00
parent 59cdedb334
commit 61710ff108
7 changed files with 113 additions and 101 deletions

10
app.go
View File

@@ -115,7 +115,7 @@ func (a *App) Setup() {
a.categories = NewCommandCategories()
for _, command := range a.Commands {
a.categories = a.categories.AddCommand(command.Category, command)
a.categories.AddCommand(command.Category, command)
}
sort.Sort(a.categories)
@@ -349,12 +349,10 @@ func (a *App) Categories() *CommandCategories {
// Hidden=false
func (a *App) VisibleCategories() []*CommandCategory {
ret := []*CommandCategory{}
for _, category := range a.categories.Categories {
for _, category := range a.categories.Categories() {
if visible := func() *CommandCategory {
for _, command := range category.Commands {
if !command.Hidden {
return category
}
if len(category.VisibleCommands()) > 0 {
return category
}
return nil
}(); visible != nil {