Feature: Add xand tag (#442)
* Feat: Add xand group and check for missing * Fix: Split and combine err in TestMultiand for consistency * Feat: Check missing required flags in xand groups * Feat: Handle combined xor and xand * Docs: Add info about combined xand and required use * Docs: Fix language error in xand description Co-authored-by: Stautis <thkrst@gmail.com> * Feat: Rename xand to and * Refactor: Switch from fmt.Sprintf to err.Error * Refactor: Get requiredAndGroup map in separate function --------- Co-authored-by: Stautis <thkrst@gmail.com>
This commit is contained in:
@@ -32,6 +32,7 @@ type Tag struct {
|
||||
Enum string
|
||||
Group string
|
||||
Xor []string
|
||||
And []string
|
||||
Vars Vars
|
||||
Prefix string // Optional prefix on anonymous structs. All sub-flags will have this prefix.
|
||||
EnvPrefix string
|
||||
@@ -249,6 +250,9 @@ func hydrateTag(t *Tag, typ reflect.Type) error { //nolint: gocyclo
|
||||
for _, xor := range t.GetAll("xor") {
|
||||
t.Xor = append(t.Xor, strings.FieldsFunc(xor, tagSplitFn)...)
|
||||
}
|
||||
for _, and := range t.GetAll("and") {
|
||||
t.And = append(t.And, strings.FieldsFunc(and, tagSplitFn)...)
|
||||
}
|
||||
t.Prefix = t.Get("prefix")
|
||||
t.EnvPrefix = t.Get("envprefix")
|
||||
t.Embed = t.Has("embed")
|
||||
|
||||
Reference in New Issue
Block a user