Only prepend EnvPrefix if .Env is not empty.

Before this change the EnvPrefix was applied to fields without env
specified, which resulted in strange and confusing help output.
This commit is contained in:
Connor Hindley
2021-11-17 11:01:40 -07:00
committed by Alec Thomas
parent 2770a34ce6
commit ea18c73f11
+3 -1
View File
@@ -139,7 +139,9 @@ MAIN:
name = tag.Prefix + name
}
tag.Env = tag.EnvPrefix + tag.Env
if tag.Env != "" {
tag.Env = tag.EnvPrefix + tag.Env
}
// Nested structs are either commands or args, unless they implement the Mapper interface.
if field.value.Kind() == reflect.Struct && (tag.Cmd || tag.Arg) && k.registry.ForValue(fv) == nil {