Merge pull request #1499 from dearchap/issue_557

Fix help results inconsistency
This commit is contained in:
dearchap
2022-09-23 08:15:07 -04:00
committed by GitHub
7 changed files with 97 additions and 44 deletions

View File

@@ -170,7 +170,7 @@ func (c *Command) Run(ctx *Context) (err error) {
}
if c.Action == nil {
c.Action = helpSubcommand.Action
c.Action = helpCommand.Action
}
cCtx.Command = c
@@ -284,7 +284,7 @@ func (c *Command) startApp(ctx *Context) error {
if c.Action != nil {
app.Action = c.Action
} else {
app.Action = helpSubcommand.Action
app.Action = helpCommand.Action
}
app.OnUsageError = c.OnUsageError
@@ -298,7 +298,12 @@ func (c *Command) startApp(ctx *Context) error {
// VisibleFlagCategories returns a slice containing all the visible flag categories with the flags they contain
func (c *Command) VisibleFlagCategories() []VisibleFlagCategory {
if c.flagCategories == nil {
return []VisibleFlagCategory{}
c.flagCategories = newFlagCategories()
for _, fl := range c.Flags {
if cf, ok := fl.(CategorizableFlag); ok {
c.flagCategories.AddFlag(cf.GetCategory(), cf)
}
}
}
return c.flagCategories.VisibleCategories()
}