(cmd *cobra.Command, f *Flag, result *string, fn pickerOptionsFunc, isUpdate bool)
| 220 | } |
| 221 | |
| 222 | func pickFlag(cmd *cobra.Command, f *Flag, result *string, fn pickerOptionsFunc, isUpdate bool) error { |
| 223 | if shouldAsk(cmd, f, isUpdate) { |
| 224 | var opts pickerOptions |
| 225 | err := ansi.Waiting(func() error { |
| 226 | var err error |
| 227 | opts, err = fn(cmd.Context()) |
| 228 | return err |
| 229 | }) |
| 230 | |
| 231 | if err != nil { |
| 232 | return err |
| 233 | } |
| 234 | |
| 235 | defaultLabel := opts.defaultLabel() |
| 236 | var val string |
| 237 | if err := selectFlag(cmd, f, &val, opts.labels(), &defaultLabel, isUpdate); err != nil { |
| 238 | return err |
| 239 | } |
| 240 | |
| 241 | *result = opts.getValue(val) |
| 242 | } |
| 243 | |
| 244 | return nil |
| 245 | } |
| 246 | |
| 247 | func pickManyFlag(cmd *cobra.Command, f *Flag, result *[]string, fn pickerOptionsFunc) error { |
| 248 | if shouldAsk(cmd, f, false) { |
no test coverage detected