Skip to content

Commit 48c5770

Browse files
adding theme to form
1 parent b94f6e1 commit 48c5770

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

cmd/speed/speed.go

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ import (
1919
"strings"
2020
)
2121

22-
// SpeedStatFunc is a function type for getting a Pokémon's base speed stat
23-
2422
// DefaultSpeedStat is the default implementation of SpeedStatFunc
2523
var DefaultSpeedStat SpeedStatFunc = func(name string) (string, error) {
2624
pokemonStruct, _, err := connections.PokemonApiCall("pokemon", name, connections.APIURL)
@@ -30,7 +28,7 @@ var DefaultSpeedStat SpeedStatFunc = func(name string) (string, error) {
3028

3129
for _, stat := range pokemonStruct.Stats {
3230
if stat.Stat.Name == "speed" {
33-
return fmt.Sprintf("%d", stat.BaseStat), nil
31+
return strconv.Itoa(stat.BaseStat), nil
3432
}
3533
}
3634

@@ -87,6 +85,7 @@ type PokemonDetails struct {
8785
SpeedIV string
8886
}
8987

88+
// SpeedStatFunc is a function type for getting a Pokémon's base speed stat
9089
type SpeedStatFunc func(name string) (string, error)
9190

9291
func SpeedCommand() (string, error) {
@@ -136,14 +135,21 @@ func SpeedCommand() (string, error) {
136135

137136
func form() *huh.Form {
138137
form := huh.NewForm(
139-
//TODO: add welcome screen
140-
// Page 2
138+
huh.NewGroup(huh.NewNote().
139+
Title("Speed Calculator").
140+
Description("This command will calculate the speed stat\nof a Pokémon during an in-game battle.").
141+
Next(true).
142+
NextLabel("Next"),
143+
),
141144
huh.NewGroup(
142145
huh.NewInput().
143146
Value(&pokemon.Name).
144147
Title("Enter the first Pokémon's name:").
145-
Placeholder("cacturne").
148+
Placeholder("incineroar").
146149
Validate(func(s string) error {
150+
if strings.TrimSpace(s) == "" {
151+
return errors.New("input cannot be blank")
152+
}
147153
_, _, err := connections.PokemonApiCall("pokemon", s, connections.APIURL)
148154
if err != nil {
149155
return errors.New("not a valid Pokémon")
@@ -174,7 +180,7 @@ func form() *huh.Form {
174180
if err != nil {
175181
return errors.New("please enter a valid number")
176182
}
177-
if num < 1 || num > 252 {
183+
if num < 0 || num > 252 {
178184
return errors.New("level must be between 0 and 252")
179185
}
180186
return nil
@@ -189,7 +195,7 @@ func form() *huh.Form {
189195
if err != nil {
190196
return errors.New("please enter a valid number")
191197
}
192-
if num < 1 || num > 31 {
198+
if num < 0 || num > 31 {
193199
return errors.New("level must be between 0 and 31")
194200
}
195201
return nil
@@ -239,7 +245,7 @@ func form() *huh.Form {
239245
return nil
240246
}),
241247
),
242-
)
248+
).WithTheme(styling.FormTheme())
243249

244250
return form
245251
}

0 commit comments

Comments
 (0)