Add Context.GlobalFlagNames()

This commit is contained in:
Artem Nezvigin 2014-10-02 15:16:29 -07:00
parent f7ebb761e8
commit 6db418e461

View File

@ -128,6 +128,18 @@ func (c *Context) FlagNames() (names []string) {
return return
} }
// Returns a slice of global flag names used by the app.
func (c *Context) GlobalFlagNames() (names []string) {
for _, flag := range c.App.Flags {
name := strings.Split(flag.getName(), ",")[0]
if name == "help" || name == "version" {
continue
}
names = append(names, name)
}
return
}
type Args []string type Args []string
// Returns the command line arguments associated with the context. // Returns the command line arguments associated with the context.