fix: add an xorprefix:"..." option for prefixing xor/and groups

Fixes #343
This commit is contained in:
Alec Thomas
2024-12-29 17:53:41 +09:00
parent cacaace969
commit 47b090f2f4
4 changed files with 31 additions and 1 deletions
+2
View File
@@ -48,6 +48,7 @@ type Tag struct {
Vars Vars
Prefix string // Optional prefix on anonymous structs. All sub-flags will have this prefix.
EnvPrefix string
XorPrefix string // Optional prefix on XOR/AND groups.
Embed bool
Aliases []string
Negatable string
@@ -268,6 +269,7 @@ func hydrateTag(t *Tag, typ reflect.Type) error { //nolint: gocyclo
}
t.Prefix = t.Get("prefix")
t.EnvPrefix = t.Get("envprefix")
t.XorPrefix = t.Get("xorprefix")
t.Embed = t.Has("embed")
if t.Has("negatable") {
if !isBool && !isBoolPtr {