Basic working flag category support
This commit is contained in:
17
app.go
17
app.go
@@ -145,6 +145,14 @@ func (a *App) Setup() {
|
||||
if c.HelpName == "" {
|
||||
c.HelpName = fmt.Sprintf("%s %s", a.HelpName, c.Name)
|
||||
}
|
||||
|
||||
fc := FlagCategories{}
|
||||
for _, flag := range c.Flags {
|
||||
fc = fc.AddFlag(flag.GetCategory(), flag)
|
||||
}
|
||||
|
||||
sort.Sort(fc)
|
||||
c.FlagCategories = fc
|
||||
newCmds = append(newCmds, c)
|
||||
}
|
||||
a.Commands = newCmds
|
||||
@@ -166,7 +174,7 @@ func (a *App) Setup() {
|
||||
}
|
||||
sort.Sort(a.categories)
|
||||
|
||||
if a.Metadata == nil {
|
||||
if a.Metadata == nil {
|
||||
a.Metadata = make(map[string]interface{})
|
||||
}
|
||||
|
||||
@@ -194,11 +202,6 @@ func (a *App) Run(arguments []string) (err error) {
|
||||
return err
|
||||
}
|
||||
|
||||
a.flagCategories = FlagCategories{}
|
||||
for _, flag := range a.Flags {
|
||||
a.flagCategories = a.flagCategories.AddFlag(flag.GetCategory(), flag)
|
||||
}
|
||||
|
||||
set.SetOutput(ioutil.Discard)
|
||||
err = set.Parse(arguments[1:])
|
||||
nerr := normalizeFlags(a.Flags, set)
|
||||
@@ -445,7 +448,7 @@ func (a *App) VisibleCommands() []Command {
|
||||
}
|
||||
|
||||
// Categories returns a slice containing all the categories with the commands they contain
|
||||
func (a *App) FlagCategories() FlagCategories {
|
||||
func (a *App) VisibleFlagCategories() FlagCategories {
|
||||
return a.flagCategories
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user