| 1 | package main |
| 2 | |
| 3 | import "github.com/charmbracelet/huh" |
| 4 | |
| 5 | type Pokemon struct { |
| 6 | id int |
| 7 | name string |
| 8 | } |
| 9 | |
| 10 | var pokemons = []Pokemon{ |
| 11 | {1, "Bulbasaur"}, |
| 12 | {2, "Ivysaur"}, |
| 13 | {3, "Venusaur"}, |
| 14 | {4, "Charmander"}, |
| 15 | {5, "Charmeleon"}, |
| 16 | {6, "Charizard"}, |
| 17 | {7, "Squirtle"}, |
| 18 | {8, "Wartortle"}, |
| 19 | {9, "Blastoise"}, |
| 20 | {10, "Caterpie"}, |
| 21 | {11, "Metapod"}, |
| 22 | {12, "Butterfree"}, |
| 23 | {13, "Weedle"}, |
| 24 | {14, "Kakuna"}, |
| 25 | {15, "Beedrill"}, |
| 26 | {16, "Pidgey"}, |
| 27 | {17, "Pidgeotto"}, |
| 28 | {18, "Pidgeot"}, |
| 29 | {19, "Rattata"}, |
| 30 | {20, "Raticate"}, |
| 31 | {21, "Spearow"}, |
| 32 | {22, "Fearow"}, |
| 33 | {23, "Ekans"}, |
| 34 | {24, "Arbok"}, |
| 35 | {25, "Pikachu"}, |
| 36 | {26, "Raichu"}, |
| 37 | {27, "Sandshrew"}, |
| 38 | {28, "Sandslash"}, |
| 39 | } |
| 40 | |
| 41 | func (p Pokemon) String() string { |
| 42 | return p.name |
| 43 | } |
| 44 | |
| 45 | func main() { |
| 46 | var pokemon Pokemon |
| 47 | |
| 48 | s := huh.NewSelect[Pokemon](). |
| 49 | Title("Choose your starter"). |
| 50 | Options(huh.NewOptions(pokemons...)...). |
| 51 | Value(&pokemon). |
| 52 | WithHeight(7) |
| 53 | |
| 54 | huh.NewForm(huh.NewGroup(s)).Run() |
| 55 | } |