SelectOrNew is the same as Select but show a create new option at the bottom of the list When create new is selected the returned bool will be true
(ask question.Asker, questionText string, itemsCallback func() ([]T, error), getKey func(item T) string)
| 55 | // SelectOrNew is the same as Select but show a create new option at the bottom of the list |
| 56 | // When create new is selected the returned bool will be true |
| 57 | func SelectOrNew[T any](ask question.Asker, questionText string, itemsCallback func() ([]T, error), getKey func(item T) string) (T, bool, error) { |
| 58 | items, err := itemsCallback() |
| 59 | if err != nil { |
| 60 | var item T |
| 61 | return item, false, err |
| 62 | } |
| 63 | return question.SelectMapWithNew(ask, questionText, items, getKey) |
| 64 | } |
no test coverage detected