Fix(issue #631). Remove reflect calls for Hidden field
This commit is contained in:
committed by
Naveen Gogineni
parent
13ded1e7c4
commit
df595c0d85
11
flag.go
11
flag.go
@@ -118,6 +118,14 @@ type DocGenerationFlag interface {
|
||||
GetValue() string
|
||||
}
|
||||
|
||||
// VisibleFlag is an interface that allows to check if a flag is visible
|
||||
type VisibleFlag interface {
|
||||
Flag
|
||||
|
||||
// IsVisible returns true if the flag is not hidden, otherwise false
|
||||
IsVisible() bool
|
||||
}
|
||||
|
||||
func flagSet(name string, flags []Flag) (*flag.FlagSet, error) {
|
||||
set := flag.NewFlagSet(name, flag.ContinueOnError)
|
||||
|
||||
@@ -133,8 +141,7 @@ func flagSet(name string, flags []Flag) (*flag.FlagSet, error) {
|
||||
func visibleFlags(fl []Flag) []Flag {
|
||||
var visible []Flag
|
||||
for _, f := range fl {
|
||||
field := flagValue(f).FieldByName("Hidden")
|
||||
if !field.IsValid() || !field.Bool() {
|
||||
if vf, ok := f.(VisibleFlag); ok && vf.IsVisible() {
|
||||
visible = append(visible, f)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user