Skip to content

Commit 7622993

Browse files
adding move endpoint as search option (#128)
1 parent 49d0099 commit 7622993

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

cmd/search/model_input.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,14 @@ func RenderInput(m Model) (string, string) {
6767

6868
switch m.Choice {
6969
case 0:
70-
msg = "Enter a Pokémon name:"
71-
endpoint = "pokemon"
72-
case 1:
7370
msg = "Enter an Ability name:"
7471
endpoint = "ability"
72+
case 1:
73+
msg = "Enter a Move name:"
74+
endpoint = "move"
75+
case 2:
76+
msg = "Enter a Pokémon name:"
77+
endpoint = "ability"
7578
default:
7679
msg = "Enter your search query:"
7780
}

cmd/search/model_selection.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ func UpdateSelection(msg tea.Msg, m Model) (tea.Model, tea.Cmd) {
1414
switch msg.String() {
1515
case "down":
1616
m.Choice++
17-
if m.Choice > 1 {
18-
m.Choice = 1
17+
if m.Choice > 2 {
18+
m.Choice = 2
1919
}
2020
case "up":
2121
m.Choice--
@@ -36,9 +36,10 @@ func RenderSelection(m Model) string {
3636
c := m.Choice
3737
greeting := styling.StyleItalic.Render("Search for a resource and return a matching selection table")
3838
choices := fmt.Sprintf(
39-
"%s\n%s",
40-
checkbox("Pokémon", c == 0),
41-
checkbox("Ability", c == 1),
39+
"%s\n%s\n%s",
40+
checkbox("Ability", c == 0),
41+
checkbox("Move", c == 1),
42+
checkbox("Pokémon", c == 2),
4243
)
4344
help := styling.KeyMenu.Render("↑ (move up) • ↓ (move down)\nenter (select) • ctrl+c | esc (quit)")
4445

0 commit comments

Comments
 (0)