MCPcopy
hub / github.com/spf13/cobra / validateRequiredFlagGroups

Function validateRequiredFlagGroups

flag_groups.go:144–165  ·  view source on GitHub ↗
(data map[string]map[string]bool)

Source from the content-addressed store, hash-verified

142}
143
144func validateRequiredFlagGroups(data map[string]map[string]bool) error {
145 keys := sortedKeys(data)
146 for _, flagList := range keys {
147 flagnameAndStatus := data[flagList]
148
149 unset := []string{}
150 for flagname, isSet := range flagnameAndStatus {
151 if !isSet {
152 unset = append(unset, flagname)
153 }
154 }
155 if len(unset) == len(flagnameAndStatus) || len(unset) == 0 {
156 continue
157 }
158
159 // Sort values, so they can be tested/scripted against consistently.
160 sort.Strings(unset)
161 return fmt.Errorf("if any flags in the group [%v] are set they must all be set; missing %v", flagList, unset)
162 }
163
164 return nil
165}
166
167func validateOneRequiredFlagGroups(data map[string]map[string]bool) error {
168 keys := sortedKeys(data)

Callers 1

ValidateFlagGroupsMethod · 0.85

Calls 1

sortedKeysFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…