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
+2 -3
View File
@@ -19,6 +19,7 @@ type Tag struct {
Name string
Help string
Type string
TypeName string
Default string
Format string
PlaceHolder string
@@ -183,6 +184,7 @@ func hydrateTag(t *Tag, typeName string, isBool bool) error {
t.Name = t.Get("name")
t.Help = t.Get("help")
t.Type = t.Get("type")
t.TypeName = typeName
t.Env = t.Get("env")
t.Short, err = t.GetRune("short")
if err != nil && t.Get("short") != "" {
@@ -217,9 +219,6 @@ func hydrateTag(t *Tag, typeName string, isBool bool) error {
t.Vars[parts[0]] = parts[1]
}
t.PlaceHolder = t.Get("placeholder")
if t.PlaceHolder == "" {
t.PlaceHolder = strings.ToUpper(dashedString(typeName))
}
t.Enum = t.Get("enum")
if t.Enum != "" && !(t.Required || t.Default != "") {
return fmt.Errorf("enum value is only valid if it is either required or has a valid default value")