diff --git a/flag.go b/flag.go index 077a6dd..524de42 100644 --- a/flag.go +++ b/flag.go @@ -203,12 +203,9 @@ func withEnvHint(envVars []string, str string) string { return str + envText } -func flagNames(f Flag) []string { +func flagNames(name string, aliases []string) []string { var ret []string - name := flagStringField(f, "Name") - aliases := flagStringSliceField(f, "Aliases") - for _, part := range append([]string{name}, aliases...) { // v1 -> v2 migration warning zone: // Strip off anything after the first found comma or space, which @@ -231,17 +228,6 @@ func flagStringSliceField(f Flag, name string) []string { return []string{} } -func flagStringField(f Flag, name string) string { - fv := flagValue(f) - field := fv.FieldByName(name) - - if field.IsValid() { - return field.String() - } - - return "" -} - func withFileHint(filePath, str string) string { fileText := "" if filePath != "" { diff --git a/flag_bool.go b/flag_bool.go index 6a1da61..bc9ea35 100644 --- a/flag_bool.go +++ b/flag_bool.go @@ -34,7 +34,7 @@ func (f *BoolFlag) String() string { // Names returns the names of the flag func (f *BoolFlag) Names() []string { - return flagNames(f) + return flagNames(f.Name, f.Aliases) } // IsRequired returns whether or not the flag is required diff --git a/flag_duration.go b/flag_duration.go index 2c34944..22a2e67 100644 --- a/flag_duration.go +++ b/flag_duration.go @@ -34,7 +34,7 @@ func (f *DurationFlag) String() string { // Names returns the names of the flag func (f *DurationFlag) Names() []string { - return flagNames(f) + return flagNames(f.Name, f.Aliases) } // IsRequired returns whether or not the flag is required diff --git a/flag_float64.go b/flag_float64.go index 31f06f3..91c778c 100644 --- a/flag_float64.go +++ b/flag_float64.go @@ -34,7 +34,7 @@ func (f *Float64Flag) String() string { // Names returns the names of the flag func (f *Float64Flag) Names() []string { - return flagNames(f) + return flagNames(f.Name, f.Aliases) } // IsRequired returns whether or not the flag is required diff --git a/flag_float64_slice.go b/flag_float64_slice.go index 91d2e9d..5f6ae72 100644 --- a/flag_float64_slice.go +++ b/flag_float64_slice.go @@ -90,7 +90,7 @@ func (f *Float64SliceFlag) String() string { // Names returns the names of the flag func (f *Float64SliceFlag) Names() []string { - return flagNames(f) + return flagNames(f.Name, f.Aliases) } // IsRequired returns whether or not the flag is required diff --git a/flag_generic.go b/flag_generic.go index 2d9baa7..b0c8ff4 100644 --- a/flag_generic.go +++ b/flag_generic.go @@ -39,7 +39,7 @@ func (f *GenericFlag) String() string { // Names returns the names of the flag func (f *GenericFlag) Names() []string { - return flagNames(f) + return flagNames(f.Name, f.Aliases) } // IsRequired returns whether or not the flag is required diff --git a/flag_int.go b/flag_int.go index be961bf..ac39d4a 100644 --- a/flag_int.go +++ b/flag_int.go @@ -34,7 +34,7 @@ func (f *IntFlag) String() string { // Names returns the names of the flag func (f *IntFlag) Names() []string { - return flagNames(f) + return flagNames(f.Name, f.Aliases) } // IsRequired returns whether or not the flag is required diff --git a/flag_int64.go b/flag_int64.go index c979119..e099912 100644 --- a/flag_int64.go +++ b/flag_int64.go @@ -34,7 +34,7 @@ func (f *Int64Flag) String() string { // Names returns the names of the flag func (f *Int64Flag) Names() []string { - return flagNames(f) + return flagNames(f.Name, f.Aliases) } // IsRequired returns whether or not the flag is required diff --git a/flag_int64_slice.go b/flag_int64_slice.go index 41aa066..edc3908 100644 --- a/flag_int64_slice.go +++ b/flag_int64_slice.go @@ -91,7 +91,7 @@ func (f *Int64SliceFlag) String() string { // Names returns the names of the flag func (f *Int64SliceFlag) Names() []string { - return flagNames(f) + return flagNames(f.Name, f.Aliases) } // IsRequired returns whether or not the flag is required diff --git a/flag_int_slice.go b/flag_int_slice.go index 9388978..94479f6 100644 --- a/flag_int_slice.go +++ b/flag_int_slice.go @@ -102,7 +102,7 @@ func (f *IntSliceFlag) String() string { // Names returns the names of the flag func (f *IntSliceFlag) Names() []string { - return flagNames(f) + return flagNames(f.Name, f.Aliases) } // IsRequired returns whether or not the flag is required diff --git a/flag_path.go b/flag_path.go index a322857..8070dc4 100644 --- a/flag_path.go +++ b/flag_path.go @@ -30,7 +30,7 @@ func (f *PathFlag) String() string { // Names returns the names of the flag func (f *PathFlag) Names() []string { - return flagNames(f) + return flagNames(f.Name, f.Aliases) } // IsRequired returns whether or not the flag is required diff --git a/flag_string.go b/flag_string.go index bcd8253..400bb53 100644 --- a/flag_string.go +++ b/flag_string.go @@ -31,7 +31,7 @@ func (f *StringFlag) String() string { // Names returns the names of the flag func (f *StringFlag) Names() []string { - return flagNames(f) + return flagNames(f.Name, f.Aliases) } // IsRequired returns whether or not the flag is required diff --git a/flag_string_slice.go b/flag_string_slice.go index a114a49..71bfef2 100644 --- a/flag_string_slice.go +++ b/flag_string_slice.go @@ -86,7 +86,7 @@ func (f *StringSliceFlag) String() string { // Names returns the names of the flag func (f *StringSliceFlag) Names() []string { - return flagNames(f) + return flagNames(f.Name, f.Aliases) } // IsRequired returns whether or not the flag is required diff --git a/flag_timestamp.go b/flag_timestamp.go index d24edcd..9fac1d1 100644 --- a/flag_timestamp.go +++ b/flag_timestamp.go @@ -86,7 +86,7 @@ func (f *TimestampFlag) String() string { // Names returns the names of the flag func (f *TimestampFlag) Names() []string { - return flagNames(f) + return flagNames(f.Name, f.Aliases) } // IsRequired returns whether or not the flag is required diff --git a/flag_uint.go b/flag_uint.go index 9f59238..2e5e76b 100644 --- a/flag_uint.go +++ b/flag_uint.go @@ -34,7 +34,7 @@ func (f *UintFlag) String() string { // Names returns the names of the flag func (f *UintFlag) Names() []string { - return flagNames(f) + return flagNames(f.Name, f.Aliases) } // IsRequired returns whether or not the flag is required diff --git a/flag_uint64.go b/flag_uint64.go index 5bbd1fa..8fc3289 100644 --- a/flag_uint64.go +++ b/flag_uint64.go @@ -34,7 +34,7 @@ func (f *Uint64Flag) String() string { // Names returns the names of the flag func (f *Uint64Flag) Names() []string { - return flagNames(f) + return flagNames(f.Name, f.Aliases) } // IsRequired returns whether or not the flag is required