Merge branch 'add-flag-category-support' of ssh://github.com/michaeljs1990/cli into michaeljs1990-add-flag-category-support

This commit is contained in:
2022-04-22 13:56:03 -04:00
5 changed files with 67 additions and 2 deletions

View File

@@ -39,6 +39,8 @@ type Command struct {
Subcommands []*Command
// List of flags to parse
Flags []Flag
// List of all flag categories
FlagCategories FlagCategories
// Treat all flags as normal arguments if true
SkipFlagParsing bool
// Boolean to hide built-in help command and help flag
@@ -280,6 +282,11 @@ func (c *Command) startApp(ctx *Context) error {
return app.RunAsSubcommand(ctx)
}
// Categories returns a slice containing all the categories with the commands they contain
func (c Command) VisibleFlagCategories() FlagCategories {
return c.FlagCategories
}
// VisibleFlags returns a slice of the Flags with Hidden=false
func (c *Command) VisibleFlags() []Flag {
return visibleFlags(c.Flags)