PostParse populates the flag given the flag set and environment
()
| 127 | |
| 128 | // PostParse populates the flag given the flag set and environment |
| 129 | func (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 |
| 153 | func (f *FlagBase[T, C, V]) setMultiValueParsingConfig(c multiValueParsingConfig) { |
nothing calls this directly
no test coverage detected