Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions flag_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,17 +247,15 @@ func (f *FlagBase[T, C, V]) GetEnvVars() []string {

// TakesValue returns true if the flag takes a value, otherwise false
func (f *FlagBase[T, C, V]) TakesValue() bool {
var t T
return reflect.TypeOf(t) == nil || reflect.TypeOf(t).Kind() != reflect.Bool
return reflect.TypeOf(f.Value) == nil || reflect.TypeOf(f.Value).Kind() != reflect.Bool
}

// GetDefaultText returns the default text for this flag
func (f *FlagBase[T, C, V]) GetDefaultText() string {
if f.DefaultText != "" {
return f.DefaultText
}
var v V
return v.ToString(f.Value)
return f.creator.ToString(f.Value)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is f.creator hasnt been initialized yet ? Define a flag(with empty DefaultText) and call GetDefaultTtext without doing a cmd.Run and see what happens. It is likely the code will crash

}

// RunAction executes flag action if set
Expand Down