Fix that default should not override the placeholder.

Fixes #243.
This commit is contained in:
Mitar
2021-12-02 12:35:12 +01:00
committed by Alec Thomas
parent d564bd286f
commit c3703cda7e
3 changed files with 11 additions and 7 deletions
+6 -3
View File
@@ -400,21 +400,24 @@ func (f *Flag) FormatPlaceHolder() string {
if f.Value.IsSlice() && f.Value.Tag.Sep != -1 {
tail += string(f.Value.Tag.Sep) + "..."
}
if f.PlaceHolder != "" {
return f.PlaceHolder + tail
}
if f.Default != "" {
if f.Value.Target.Kind() == reflect.String {
return strconv.Quote(f.Default) + tail
}
return f.Default + tail
}
if f.PlaceHolder != "" {
return f.PlaceHolder + tail
}
if f.Value.IsMap() {
if f.Value.Tag.MapSep != -1 {
tail = string(f.Value.Tag.MapSep) + "..."
}
return "KEY=VALUE" + tail
}
if f.Tag != nil && f.Tag.TypeName != "" {
return strings.ToUpper(dashedString(f.Tag.TypeName)) + tail
}
return strings.ToUpper(f.Name) + tail
}