feat: `gum choose`, pick from a list of choices
gum choose allows the user to be prompted for a choice from a list of choices.
For example, let's ask the user to pick a card from a deck.
gum choose --height 15 {Ace,King,Queen,Jack,Ten,Nine,Eight,Seven,Six,Five,Four,Three,Two}" of "{Spades,Hearts,Clubs,Diamonds}
2022-07-11 22:17:47 +02:00
|
|
|
package choose
|
|
|
|
|
2022-07-12 22:05:40 +02:00
|
|
|
import "github.com/charmbracelet/gum/style"
|
|
|
|
|
feat: `gum choose`, pick from a list of choices
gum choose allows the user to be prompted for a choice from a list of choices.
For example, let's ask the user to pick a card from a deck.
gum choose --height 15 {Ace,King,Queen,Jack,Ten,Nine,Eight,Seven,Six,Five,Four,Three,Two}" of "{Spades,Hearts,Clubs,Diamonds}
2022-07-11 22:17:47 +02:00
|
|
|
// Options is the customization options for the choose command.
|
|
|
|
type Options struct {
|
|
|
|
Options []string `arg:"" optional:"" help:"Options to choose from."`
|
|
|
|
|
2022-07-13 18:10:38 +02:00
|
|
|
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"`
|
2023-01-12 19:36:11 +01:00
|
|
|
Ordered bool `help:"Maintain the order of the selected options" env:"GUM_CHOOSE_ORDERED"`
|
2022-08-03 23:43:32 +02:00
|
|
|
Height int `help:"Height of the list" default:"10" env:"GUM_CHOOSE_HEIGHT"`
|
2022-09-08 03:01:42 +02:00
|
|
|
Cursor string `help:"Prefix to show on item that corresponds to the cursor position" default:"> " env:"GUM_CHOOSE_CURSOR"`
|
2023-03-14 20:58:48 +01:00
|
|
|
Header string `help:"Header value" default:"" env:"GUM_CHOOSE_HEADER"`
|
2022-09-08 03:01:42 +02:00
|
|
|
CursorPrefix string `help:"Prefix to show on the cursor item (hidden if limit is 1)" default:"○ " env:"GUM_CHOOSE_CURSOR_PREFIX"`
|
|
|
|
SelectedPrefix string `help:"Prefix to show on selected items (hidden if limit is 1)" default:"◉ " env:"GUM_CHOOSE_SELECTED_PREFIX"`
|
|
|
|
UnselectedPrefix string `help:"Prefix to show on unselected items (hidden if limit is 1)" default:"○ " env:"GUM_CHOOSE_UNSELECTED_PREFIX"`
|
2022-09-06 21:02:32 +02:00
|
|
|
Selected []string `help:"Options that should start as selected" default:"" env:"GUM_CHOOSE_SELECTED"`
|
2022-08-03 23:43:32 +02:00
|
|
|
CursorStyle style.Styles `embed:"" prefix:"cursor." set:"defaultForeground=212" envprefix:"GUM_CHOOSE_CURSOR_"`
|
2023-03-14 20:58:48 +01:00
|
|
|
HeaderStyle style.Styles `embed:"" prefix:"header." set:"defaultForeground=240" envprefix:"GUM_CHOOSE_HEADER_"`
|
2022-08-03 23:43:32 +02:00
|
|
|
ItemStyle style.Styles `embed:"" prefix:"item." hidden:"" envprefix:"GUM_CHOOSE_ITEM_"`
|
|
|
|
SelectedItemStyle style.Styles `embed:"" prefix:"selected." set:"defaultForeground=212" envprefix:"GUM_CHOOSE_SELECTED_"`
|
feat: `gum choose`, pick from a list of choices
gum choose allows the user to be prompted for a choice from a list of choices.
For example, let's ask the user to pick a card from a deck.
gum choose --height 15 {Ace,King,Queen,Jack,Ten,Nine,Eight,Seven,Six,Five,Four,Three,Two}" of "{Spades,Hearts,Clubs,Diamonds}
2022-07-11 22:17:47 +02:00
|
|
|
}
|