Export cli.Flag.GetName (previously cli.Flag.getName)

This commit is contained in:
Jille Timmermans 2015-12-15 17:29:03 +00:00
parent b5232bb293
commit f101a00018
2 changed files with 13 additions and 13 deletions

View File

@ -163,7 +163,7 @@ func (c *Context) GlobalIsSet(name string) bool {
// Returns a slice of flag names used in this context. // Returns a slice of flag names used in this context.
func (c *Context) FlagNames() (names []string) { func (c *Context) FlagNames() (names []string) {
for _, flag := range c.Command.Flags { for _, flag := range c.Command.Flags {
name := strings.Split(flag.getName(), ",")[0] name := strings.Split(flag.GetName(), ",")[0]
if name == "help" { if name == "help" {
continue continue
} }
@ -175,7 +175,7 @@ func (c *Context) FlagNames() (names []string) {
// Returns a slice of global flag names used by the app. // Returns a slice of global flag names used by the app.
func (c *Context) GlobalFlagNames() (names []string) { func (c *Context) GlobalFlagNames() (names []string) {
for _, flag := range c.App.Flags { for _, flag := range c.App.Flags {
name := strings.Split(flag.getName(), ",")[0] name := strings.Split(flag.GetName(), ",")[0]
if name == "help" || name == "version" { if name == "help" || name == "version" {
continue continue
} }
@ -360,7 +360,7 @@ func normalizeFlags(flags []Flag, set *flag.FlagSet) error {
visited[f.Name] = true visited[f.Name] = true
}) })
for _, f := range flags { for _, f := range flags {
parts := strings.Split(f.getName(), ",") parts := strings.Split(f.GetName(), ",")
if len(parts) == 1 { if len(parts) == 1 {
continue continue
} }

20
flag.go
View File

@ -35,7 +35,7 @@ type Flag interface {
fmt.Stringer fmt.Stringer
// Apply Flag settings to the given flag set // Apply Flag settings to the given flag set
Apply(*flag.FlagSet) Apply(*flag.FlagSet)
getName() string GetName() string
} }
func flagSet(name string, flags []Flag) *flag.FlagSet { func flagSet(name string, flags []Flag) *flag.FlagSet {
@ -95,7 +95,7 @@ func (f GenericFlag) Apply(set *flag.FlagSet) {
}) })
} }
func (f GenericFlag) getName() string { func (f GenericFlag) GetName() string {
return f.Name return f.Name
} }
@ -159,7 +159,7 @@ func (f StringSliceFlag) Apply(set *flag.FlagSet) {
}) })
} }
func (f StringSliceFlag) getName() string { func (f StringSliceFlag) GetName() string {
return f.Name return f.Name
} }
@ -231,7 +231,7 @@ func (f IntSliceFlag) Apply(set *flag.FlagSet) {
}) })
} }
func (f IntSliceFlag) getName() string { func (f IntSliceFlag) GetName() string {
return f.Name return f.Name
} }
@ -273,7 +273,7 @@ func (f BoolFlag) Apply(set *flag.FlagSet) {
}) })
} }
func (f BoolFlag) getName() string { func (f BoolFlag) GetName() string {
return f.Name return f.Name
} }
@ -316,7 +316,7 @@ func (f BoolTFlag) Apply(set *flag.FlagSet) {
}) })
} }
func (f BoolTFlag) getName() string { func (f BoolTFlag) GetName() string {
return f.Name return f.Name
} }
@ -364,7 +364,7 @@ func (f StringFlag) Apply(set *flag.FlagSet) {
}) })
} }
func (f StringFlag) getName() string { func (f StringFlag) GetName() string {
return f.Name return f.Name
} }
@ -407,7 +407,7 @@ func (f IntFlag) Apply(set *flag.FlagSet) {
}) })
} }
func (f IntFlag) getName() string { func (f IntFlag) GetName() string {
return f.Name return f.Name
} }
@ -450,7 +450,7 @@ func (f DurationFlag) Apply(set *flag.FlagSet) {
}) })
} }
func (f DurationFlag) getName() string { func (f DurationFlag) GetName() string {
return f.Name return f.Name
} }
@ -492,7 +492,7 @@ func (f Float64Flag) Apply(set *flag.FlagSet) {
}) })
} }
func (f Float64Flag) getName() string { func (f Float64Flag) GetName() string {
return f.Name return f.Name
} }