diff --git a/pkg/command/command.go b/pkg/command/command.go index d42cf0d..9aa173c 100644 --- a/pkg/command/command.go +++ b/pkg/command/command.go @@ -22,8 +22,17 @@ type Command struct { } func (c *Command) AddFlag(f Flag) { - if c.Flags == nil { - c.Flags = make(map[string]string) + switch { + case f.Persistent: + if c.PersistentFlags == nil { + c.PersistentFlags = make(map[string]string) + } + c.PersistentFlags[f.format()] = f.Usage + + default: + if c.Flags == nil { + c.Flags = make(map[string]string) + } + c.Flags[f.format()] = f.Usage } - c.Flags[f.format()] = f.Usage } diff --git a/pkg/command/flag.go b/pkg/command/flag.go index 982fbf3..e66fe77 100644 --- a/pkg/command/flag.go +++ b/pkg/command/flag.go @@ -9,6 +9,7 @@ type Flag struct { Value bool Hidden bool Required bool + Persistent bool } func (f Flag) format() string {