This commit is contained in:
Oliver Tzeng 2023-02-02 22:40:19 +08:00
parent 78bb3b5f06
commit c3588b695e
2 changed files with 3 additions and 0 deletions

View file

@ -136,7 +136,9 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
// Then we select the item that they have pressed enter on. If they
// have selected items, then we simply return them.
if m.numSelected < 1 {
if o.AllowUnchoosen == false {
m.items[m.index].selected = true
}
}
return m, tea.Quit
}

View file

@ -8,6 +8,7 @@ type Options struct {
Limit int `help:"Maximum number of options to pick" default:"1" group:"Selection"`
NoLimit bool `help:"Pick unlimited number of options (ignores limit)" group:"Selection"`
AllowUnchoosen bool `help:"Allow gum choose to proceed when pressing enter without selecting anything" group:"Selection"`
Ordered bool `help:"Maintain the order of the selected options" env:"GUM_CHOOSE_ORDERED"`
Height int `help:"Height of the list" default:"10" env:"GUM_CHOOSE_HEIGHT"`
Cursor string `help:"Prefix to show on item that corresponds to the cursor position" default:"> " env:"GUM_CHOOSE_CURSOR"`