MCPcopy Create free account
hub / github.com/cogentcore/core / boolFlags

Function boolFlags

cli/args.go:72–96  ·  view source on GitHub ↗

boolFlags returns a map with a true value for every flag name that maps to a boolean field. This is needed so that bool flags can be properly set with their shorthand syntax.

(obj any)

Source from the content-addressed store, hash-verified

70// that maps to a boolean field. This is needed so that bool
71// flags can be properly set with their shorthand syntax.
72func boolFlags(obj any) map[string]bool {
73 fields := &fields{}
74 addFields(obj, fields, addAllFields)
75
76 res := map[string]bool{}
77
78 for _, kv := range fields.Order {
79 f := kv.Value
80
81 if f.Field.Type.Kind() != reflect.Bool { // we only care about bools here
82 continue
83 }
84
85 // we need all cases of both normal and "no" version for all names
86 for _, name := range f.Names {
87 for _, cnms := range allCases(name) {
88 res[cnms] = true
89 }
90 for _, cnms := range allCases("No" + name) {
91 res[cnms] = true
92 }
93 }
94 }
95 return res
96}
97
98// getArgs processes the given args using the given map of bool flags,
99// which should be obtained through [boolFlags]. It returns the leftover

Callers 2

SetFromArgsFunction · 0.85
TestGetArgsFunction · 0.85

Calls 3

addFieldsFunction · 0.85
allCasesFunction · 0.85
KindMethod · 0.80

Tested by 1

TestGetArgsFunction · 0.68