Merge pull request #95 from artnez/master
Add FlagNames() method to Context
This commit is contained in:
commit
c7ff3bf705
12
context.go
12
context.go
@ -105,6 +105,18 @@ func (c *Context) IsSet(name string) bool {
|
|||||||
return c.setFlags[name] == true
|
return c.setFlags[name] == true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Returns a slice of flag names used in this context.
|
||||||
|
func (c *Context) FlagNames() (names []string) {
|
||||||
|
for _, flag := range c.Command.Flags {
|
||||||
|
name := strings.Split(flag.getName(), ",")[0]
|
||||||
|
if name == "help" {
|
||||||
|
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.
|
||||||
|
Loading…
Reference in New Issue
Block a user