Remove CategorizedHelp from App and allow subcommands to have categories
Just place all subcommands in categories, the default category will be "" which will properly format the output (and group commands that have no category). Also allow subcommands to have categories. Lastly, augment the test to check the output.
This commit is contained in:
@@ -3,6 +3,7 @@ package cli
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"sort"
|
||||
"strings"
|
||||
)
|
||||
|
||||
@@ -231,6 +232,13 @@ func (c Command) startApp(ctx *Context) error {
|
||||
app.Email = ctx.App.Email
|
||||
app.Writer = ctx.App.Writer
|
||||
|
||||
app.categories = CommandCategories{}
|
||||
for _, command := range c.Subcommands {
|
||||
app.categories = app.categories.AddCommand(command.Category, command)
|
||||
}
|
||||
|
||||
sort.Sort(app.categories)
|
||||
|
||||
// bash completion
|
||||
app.EnableBashCompletion = ctx.App.EnableBashCompletion
|
||||
if c.BashComplete != nil {
|
||||
|
Reference in New Issue
Block a user