Refactor code

This commit is contained in:
Naveen Gogineni 2022-10-07 11:17:09 -05:00
parent 8227be1fe9
commit 81f9145708

View File

@ -309,14 +309,7 @@ func (c *Command) VisibleCommands() []*Command {
// VisibleFlagCategories returns a slice containing all the visible flag categories with the flags they contain
func (c *Command) VisibleFlagCategories() []VisibleFlagCategory {
if c.flagCategories == nil {
c.flagCategories = newFlagCategories()
for _, fl := range c.Flags {
if cf, ok := fl.(CategorizableFlag); ok {
if cf.GetCategory() != "" {
c.flagCategories.AddFlag(cf.GetCategory(), cf)
}
}
}
c.flagCategories = newFlagCategoriesFromFlags(c.Flags)
}
return c.flagCategories.VisibleCategories()
}