MCPcopy
hub / github.com/urfave/cli / PostParse

Method PostParse

flag_impl.go:129–150  ·  view source on GitHub ↗

PostParse populates the flag given the flag set and environment

()

Source from the content-addressed store, hash-verified

127
128// PostParse populates the flag given the flag set and environment
129func (f *FlagBase[T, C, V]) PostParse() error {
130 tracef("postparse (flag=%[1]q)", f.Name)
131
132 if !f.hasBeenSet {
133 if val, source, found := f.Sources.LookupWithSource(); found {
134 if val != "" || reflect.TypeOf(f.Value).Kind() == reflect.String {
135 if err := f.Set(f.Name, val); err != nil {
136 return fmt.Errorf(
137 "could not parse %[1]q as %[2]T value from %[3]s for flag %[4]s: %[5]s",
138 val, f.Value, source, f.Name, err,
139 )
140 }
141 } else if val == "" && reflect.TypeOf(f.Value).Kind() == reflect.Bool {
142 _ = f.Set(f.Name, "false")
143 }
144
145 f.hasBeenSet = true
146 }
147 }
148
149 return nil
150}
151
152// pass configuration of parsing to value
153func (f *FlagBase[T, C, V]) setMultiValueParsingConfig(c multiValueParsingConfig) {

Callers

nothing calls this directly

Calls 3

SetMethod · 0.95
tracefFunction · 0.85
LookupWithSourceMethod · 0.80

Tested by

no test coverage detected