Skip to content

Commit b03deb6

Browse files
adding egg group(s) to pokemon command (#188)
1 parent ba6f999 commit b03deb6

File tree

1 file changed

+21
-6
lines changed

1 file changed

+21
-6
lines changed

cmd/pokemon/pokemon.go

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"io"
88
"math"
99
"os"
10+
"sort"
1011
"strings"
1112

1213
"github.com/charmbracelet/lipgloss"
@@ -97,6 +98,18 @@ func PokemonCommand() (string, error) {
9798
}
9899
}
99100

101+
eggGroup := func(w io.Writer) {
102+
var eggGroupSlice []string
103+
104+
for _, entry := range pokemonSpeciesStruct.EggGroups {
105+
capitalizedEggGroup := cases.Title(language.English).String(entry.Name)
106+
eggGroupSlice = append(eggGroupSlice, capitalizedEggGroup)
107+
}
108+
109+
sort.Strings(eggGroupSlice)
110+
fmt.Fprintf(w, "\n%s %s %s", styling.ColoredBullet, "Egg Group(s):", strings.Join(eggGroupSlice, ", "))
111+
}
112+
100113
typing := func(w io.Writer) {
101114
var typeBoxes []string
102115

@@ -156,20 +169,22 @@ func PokemonCommand() (string, error) {
156169
}
157170

158171
var (
159-
entryOutput bytes.Buffer
160-
typeOutput bytes.Buffer
161-
metricsOutput bytes.Buffer
162-
speciesOutput bytes.Buffer
172+
entryOutput bytes.Buffer
173+
eggGroupOutput bytes.Buffer
174+
typeOutput bytes.Buffer
175+
metricsOutput bytes.Buffer
176+
speciesOutput bytes.Buffer
163177
)
164178

165179
entry(&entryOutput)
180+
eggGroup(&eggGroupOutput)
166181
typing(&typeOutput)
167182
metrics(&metricsOutput)
168183
species(&speciesOutput)
169184

170185
output.WriteString(fmt.Sprintf(
171-
"Your selected Pokémon: %s\n%s%s%s%s\n",
172-
capitalizedString, entryOutput.String(), typeOutput.String(), metricsOutput.String(), speciesOutput.String(),
186+
"Your selected Pokémon: %s\n%s\n%s%s%s%s\n",
187+
capitalizedString, entryOutput.String(), typeOutput.String(), metricsOutput.String(), speciesOutput.String(), eggGroupOutput.String(),
173188
))
174189

175190
if *imageFlag != "" || *shortImageFlag != "" {

0 commit comments

Comments
 (0)