MCPcopy
hub / github.com/spf13/pflag / VisitAll

Method VisitAll

flag.go:304–322  ·  view source on GitHub ↗

VisitAll visits the flags in lexicographical order or in primordial order if f.SortFlags is false, calling fn for each. It visits all flags, even those not set.

(fn func(*Flag))

Source from the content-addressed store, hash-verified

302// in primordial order if f.SortFlags is false, calling fn for each.
303// It visits all flags, even those not set.
304func (f *FlagSet) VisitAll(fn func(*Flag)) {
305 if len(f.formal) == 0 {
306 return
307 }
308
309 var flags []*Flag
310 if f.SortFlags {
311 if len(f.formal) != len(f.sortedFormal) {
312 f.sortedFormal = sortFlags(f.formal)
313 }
314 flags = f.sortedFormal
315 } else {
316 flags = f.orderedFormal
317 }
318
319 for _, flag := range flags {
320 fn(flag)
321 }
322}
323
324// HasFlags returns a bool to indicate if the FlagSet has any flags defined.
325func (f *FlagSet) HasFlags() bool {

Callers 15

TestVisitAllFlagOrderFunction · 0.95
CopyToGoFlagSetMethod · 0.95
FlagUsagesWrappedMethod · 0.95
TestToGoflagsFunction · 0.95
TestDSAsSliceValueFunction · 0.80
TestIPSAsSliceValueFunction · 0.80
TestUISAsSliceValueFunction · 0.80
TestI64SAsSliceValueFunction · 0.80
AddGoFlagSetMethod · 0.80
TestF32SAsSliceValueFunction · 0.80
TestF64SAsSliceValueFunction · 0.80
TestSAAsSliceValueFunction · 0.80

Calls 1

sortFlagsFunction · 0.85

Tested by 12

TestVisitAllFlagOrderFunction · 0.76
TestToGoflagsFunction · 0.76
TestDSAsSliceValueFunction · 0.64
TestIPSAsSliceValueFunction · 0.64
TestUISAsSliceValueFunction · 0.64
TestI64SAsSliceValueFunction · 0.64
TestF32SAsSliceValueFunction · 0.64
TestF64SAsSliceValueFunction · 0.64
TestSAAsSliceValueFunction · 0.64
TestI32SAsSliceValueFunction · 0.64
TestBSAsSliceValueFunction · 0.64
TestSSAsSliceValueFunction · 0.64