From 6db418e461936303d1082600f0efe23cd57f8c2c Mon Sep 17 00:00:00 2001 From: Artem Nezvigin Date: Thu, 2 Oct 2014 15:16:29 -0700 Subject: [PATCH] Add Context.GlobalFlagNames() --- context.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/context.go b/context.go index 8b44148..e4b0da6 100644 --- a/context.go +++ b/context.go @@ -128,6 +128,18 @@ func (c *Context) FlagNames() (names []string) { 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 // Returns the command line arguments associated with the context.