Basic working flag category support

This commit is contained in:
Michael Schuett
2019-01-27 15:48:00 -05:00
parent 51aebb5a03
commit 9720ac029c
3 changed files with 24 additions and 10 deletions

View File

@@ -45,6 +45,8 @@ type Command struct {
Subcommands Commands
// List of flags to parse
Flags []Flag
// List of all flag categories
FlagCategories FlagCategories
// Treat all flags as normal arguments if true
SkipFlagParsing bool
// Skip argument reordering which attempts to move flags before arguments,
@@ -377,6 +379,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)