This commit is contained in:
Martin Lees 2019-12-12 17:31:41 +01:00
parent 06eb576eaa
commit c62d7736ea
3 changed files with 7 additions and 6 deletions

View File

@ -18,11 +18,11 @@ type Float64Flag struct {
Value float64 Value float64
DefaultText string DefaultText string
Destination *float64 Destination *float64
HasBeenSet bool HasBeenSet bool
} }
// IsSet returns whether or not the flag has been set through env or file // IsSet returns whether or not the flag has been set through env or file
func (f *Float64Flag)IsSet() bool { func (f *Float64Flag) IsSet() bool {
return f.HasBeenSet return f.HasBeenSet
} }

View File

@ -8,9 +8,9 @@ import (
// Timestamp wrap to satisfy golang's flag interface. // Timestamp wrap to satisfy golang's flag interface.
type Timestamp struct { type Timestamp struct {
timestamp *time.Time timestamp *time.Time
hasBeenSet bool hasBeenSet bool
layout string layout string
} }
// Timestamp constructor // Timestamp constructor
@ -25,6 +25,7 @@ func (t *Timestamp) SetTimestamp(value time.Time) {
t.hasBeenSet = true t.hasBeenSet = true
} }
} }
// Set the timestamp string layout for future parsing // Set the timestamp string layout for future parsing
func (t *Timestamp) SetLayout(layout string) { func (t *Timestamp) SetLayout(layout string) {
t.layout = layout t.layout = layout
@ -66,7 +67,7 @@ type TimestampFlag struct {
FilePath string FilePath string
Required bool Required bool
Hidden bool Hidden bool
Layout string Layout string
Value *Timestamp Value *Timestamp
DefaultText string DefaultText string
HasBeenSet bool HasBeenSet bool

View File

@ -138,7 +138,7 @@ func printFlagSuggestions(lastArg string, flags []Flag, writer io.Writer) {
if bflag, ok := flag.(*BoolFlag); ok && bflag.Hidden { if bflag, ok := flag.(*BoolFlag); ok && bflag.Hidden {
continue continue
} }
for _, name := range flag.Names(){ for _, name := range flag.Names() {
name = strings.TrimSpace(name) name = strings.TrimSpace(name)
// this will get total count utf8 letters in flag name // this will get total count utf8 letters in flag name
count := utf8.RuneCountInString(name) count := utf8.RuneCountInString(name)