Skip to content

Commit 4f5b907

Browse files
adding correct parsing of ImageFlag() (#93)
1 parent bce9e72 commit 4f5b907

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

cmd/pokemon.go

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ import (
1515
// PokemonCommand processes the Pokémon command
1616
func PokemonCommand() {
1717

18+
hintMessage := styleItalic.Render("options: [sm, md, lg]")
19+
1820
flag.Usage = func() {
1921
helpMessage := helpBorder.Render(
2022
"Get details about a specific Pokémon.\n\n",
@@ -24,6 +26,8 @@ func PokemonCommand() {
2426
"\n\n",
2527
styleBold.Render("FLAGS:"),
2628
fmt.Sprintf("\n\t%-30s %s", "-a, --abilities", "Prints the Pokémon's abilities."),
29+
fmt.Sprintf("\n\t%-30s %s", "-i=xx, --image=xx", "Prints out the Pokémon's default sprite."),
30+
fmt.Sprintf("\n\t%5s%-15s", "", hintMessage),
2731
fmt.Sprintf("\n\t%-30s %s", "-s, --stats", "Prints the Pokémon's base stats."),
2832
fmt.Sprintf("\n\t%-30s %s", "-t, --types", "Prints the Pokémon's typing."),
2933
fmt.Sprintf("\n\t%-30s %s", "-h, --help", "Prints the help menu."),
@@ -76,15 +80,22 @@ func PokemonCommand() {
7680
capitalizedString, pokemonID, weightKilograms, weightPounds, heightFeet, feet, inches,
7781
)
7882

79-
if *abilitiesFlag || *shortAbilitiesFlag {
80-
if err := flags.AbilitiesFlag(endpoint, pokemonName); err != nil {
81-
fmt.Printf("Error: %s\n", err)
83+
if *imageFlag != "" || *shortImageFlag != "" {
84+
// Determine the size based on the provided flags
85+
size := *imageFlag
86+
if *shortImageFlag != "" {
87+
size = *shortImageFlag
88+
}
89+
90+
// Call the ImageFlag function with the specified size
91+
if err := flags.ImageFlag(endpoint, pokemonName, size); err != nil {
92+
fmt.Println(err)
8293
os.Exit(1)
8394
}
8495
}
8596

86-
if *imageFlag || *shortImageFlag {
87-
if err := flags.ImageFlag(endpoint, pokemonName); err != nil {
97+
if *abilitiesFlag || *shortAbilitiesFlag {
98+
if err := flags.AbilitiesFlag(endpoint, pokemonName); err != nil {
8899
fmt.Printf("Error: %s\n", err)
89100
os.Exit(1)
90101
}

0 commit comments

Comments
 (0)