Skip to content

Commit 4f1dde6

Browse files
Merge pull request #120 from digitalghost-dev/1.0.3
1.0.3
2 parents f90d674 + c2e9c3b commit 4f1dde6

20 files changed

+393
-108
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ on:
2626
- main
2727

2828
env:
29-
VERSION_NUMBER: 'v1.0.2'
29+
VERSION_NUMBER: 'v1.0.3'
3030
DOCKERHUB_REGISTRY_NAME: 'digitalghostdev/poke-cli'
3131
AWS_REGION: 'us-west-2'
3232

.goreleaser.yaml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ builds:
1414
- windows
1515
- darwin
1616
ldflags:
17-
- -s -w -X main.version=v1.0.2
17+
- -s -w -X main.version=v1.0.3
1818

1919
archives:
2020
- format: tar.gz
@@ -36,3 +36,12 @@ changelog:
3636
exclude:
3737
- "^docs:"
3838
- "^test:"
39+
40+
brews:
41+
- repository:
42+
owner: digitalghost-dev
43+
name: homebrew-poke-cli
44+
token: "{{.Env.GITHUB_TOKEN}}"
45+
homepage: "https://github.com/digitalghost-dev/poke-cli"
46+
description: "A CLI tool written in Go that allows you to view data about Pokémon from the terminal."
47+
license: "Apache License 2.0"

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ RUN go mod download
88

99
COPY . .
1010

11-
RUN go build -ldflags "-X main.version=v1.0.2" -o poke-cli .
11+
RUN go build -ldflags "-X main.version=v1.0.3" -o poke-cli .
1212

1313
# build 2
1414
FROM --platform=$BUILDPLATFORM alpine:latest

README.md

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<img height="250" width="350" src="pokemon.svg" alt="pokemon-logo"/>
33
<h1>Pokémon CLI</h1>
44
<img src="https://img.shields.io/github/v/release/digitalghost-dev/poke-cli?style=flat-square&logo=git&logoColor=FFCC00&label=Release%20Version&labelColor=EEE&color=FFCC00" alt="version-label">
5-
<img src="https://img.shields.io/docker/image-size/digitalghostdev/poke-cli/v1.0.2?arch=arm64&style=flat-square&logo=docker&logoColor=FFCC00&labelColor=EEE&color=FFCC00" alt="docker-image-size">
5+
<img src="https://img.shields.io/docker/image-size/digitalghostdev/poke-cli/v1.0.3?arch=arm64&style=flat-square&logo=docker&logoColor=FFCC00&labelColor=EEE&color=FFCC00" alt="docker-image-size">
66
<img src="https://img.shields.io/github/actions/workflow/status/digitalghost-dev/poke-cli/ci.yml?branch=main&style=flat-square&logo=github&logoColor=FFCC00&label=CI&labelColor=EEE&color=FFCC00" alt="ci-status-badge">
77
</div>
88
<div align="center">
@@ -56,7 +56,7 @@ _Download a pre-built binary_
5656
.\poke-cli.exe pokemon charizard --types --abilities
5757

5858
# Unix
59-
.\poke-cli pokemon vespiquen -t -a
59+
.\poke-cli ability airlock --pokemon
6060
```
6161

6262
### Docker Image
@@ -73,11 +73,11 @@ _Use a Docker Image_
7373
3. Choose how to interact with the container:
7474
* Run a single command and exit:
7575
```bash
76-
docker run --rm -it digitalghostdev/poke-cli:v1.0.2 <command> [subcommand] flag]
76+
docker run --rm -it digitalghostdev/poke-cli:v1.0.3 <command> [subcommand] flag]
7777
```
7878
* Enter the container and use its shell:
7979
```bash
80-
docker run --rm -it --name poke-cli --entrypoint /bin/sh digitalghostdev/poke-cli:v1.0.2 -c "cd /app && exec sh"
80+
docker run --rm -it --name poke-cli --entrypoint /bin/sh digitalghostdev/poke-cli:v1.0.3 -c "cd /app && exec sh"
8181
# placed into the /app directory, run the program with './poke-cli'
8282
# example: ./poke-cli ability swift-swim
8383
```
@@ -142,10 +142,13 @@ Below is a list of the planned/completed commands and flags:
142142

143143
---
144144
## Tested Terminals
145-
| OS | Terminal | Status | Issues |
146-
|---------|--------------------|:------:|-------------------------------|
147-
| macOS | Ghostty || None |
148-
| macOS | Alacritty || None |
149-
| macOS | macOS Terminal | ⚠️ | Images do not render properly |
150-
| Windows | Windows Terminal || None |
151-
| Ubuntu | Standard Terminal || None |
145+
| OS | Terminal | Status | Issues |
146+
|---------|-------------------|:------:|-------------------------------|
147+
| macOS | Ghostty || None |
148+
| macOS | Alacritty || None |
149+
| macOS | HyperJS || None |
150+
| macOS | iTerm2 || None |
151+
| macOS | macOS Terminal | ⚠️ | Images do not render properly |
152+
| Windows | Windows Terminal || None |
153+
| Ubuntu | Standard Terminal || None |
154+
| Ubuntu | Tabby || None |

cli_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ func TestCurrentVersion(t *testing.T) {
1515
}{
1616
{
1717
name: "Version set by ldflags",
18-
version: "v1.0.0",
19-
expectedOutput: "Version: v1.0.0\n",
18+
version: "v1.0.2",
19+
expectedOutput: "Version: v1.0.2\n",
2020
},
2121
{
2222
name: "Version set to (devel)",
@@ -186,7 +186,7 @@ func TestRunCLI(t *testing.T) {
186186
{
187187
name: "Latest Flag",
188188
args: []string{"-l"},
189-
expectedOutput: "Latest Docker image version: v1.0.1\nLatest release tag: v1.0.1\n",
189+
expectedOutput: "Latest Docker image version: v1.0.2\nLatest release tag: v1.0.2\n",
190190
expectedCode: 0,
191191
},
192192
}

cmd/ability.go

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,34 @@ func AbilityCommand() {
6969
}
7070
}
7171

72-
capitalizedEffect := cases.Title(language.English).String(strings.Replace(abilityName, "-", " ", -1))
73-
fmt.Println(styling.StyleBold.Render(capitalizedEffect))
74-
fmt.Println("Effect:", englishShortEffect)
72+
// Extract English flavor_text_entries
73+
var englishFlavorEntry string
74+
for _, entry := range abilitiesStruct.FlavorEntries {
75+
if entry.Language.Name == "en" {
76+
englishFlavorEntry = entry.FlavorText
77+
break
78+
}
79+
}
80+
81+
capitalizedAbility := cases.Title(language.English).String(strings.Replace(abilityName, "-", " ", -1))
82+
fmt.Println(styling.StyleBold.Render(capitalizedAbility))
83+
84+
// API is missing some data for the short_effect for abilities from Generation 9.
85+
// If short_effect is empty, fallback to the move's flavor_text_entry.
86+
if englishShortEffect == "" {
87+
fmt.Println("Effect:", englishFlavorEntry)
88+
} else {
89+
fmt.Println("Effect:", englishShortEffect)
90+
}
91+
92+
// Print the generation where the move was first introduced.
93+
generationParts := strings.Split(abilitiesStruct.Generation.Name, "-")
94+
if len(generationParts) > 1 {
95+
generationUpper := strings.ToUpper(generationParts[1])
96+
fmt.Println("Generation:", generationUpper)
97+
} else {
98+
fmt.Println("Generation: Unknown")
99+
}
75100

76101
if *pokemonFlag || *shortPokemonFlag {
77102
if err := flags.PokemonFlag(endpoint, abilityName); err != nil {

cmd/ability_test.go

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,27 @@ func TestAbilityCommand(t *testing.T) {
6262
{
6363
name: "Valid Execution",
6464
args: []string{"ability", "stench"},
65-
expectedOutput: styling.StripANSI("Stench\nEffect: Has a 10% chance of making target Pokémon flinch with each hit."),
65+
expectedOutput: styling.StripANSI("Stench\nEffect: Has a 10% chance of making target Pokémon flinch with each hit.\nGeneration: III"),
6666
expectError: false,
6767
},
68+
{
69+
name: "Valid Execution",
70+
args: []string{"ability", "poison-puppeteer", "--pokemon"},
71+
expectedOutput: styling.StripANSI("Poison Puppeteer\nEffect: Pokémon poisoned by Pecharunt's moves will also become confused.\nGeneration: IX\n\nPokemon with Poison Puppeteer\n\n 1. Pecharunt"),
72+
expectError: false,
73+
},
74+
{
75+
name: "Valid Execution",
76+
args: []string{"ability", "corrosion", "-p"},
77+
expectedOutput: styling.StripANSI(fmt.Sprintf(
78+
"Corrosion\nEffect: This Pokémon can inflict poison on Poison and Steel Pokémon.\nGeneration: VII\n\nPokemon with Corrosion\n\n"+
79+
"%2d. %-30s%2d. %-30s%2d. %-30s\n"+
80+
"%2d. %-30s%2d. %-30s",
81+
1, "Salandit", 2, "Salazzle", 3, "Glimmet",
82+
4, "Glimmora", 5, "Salazzle-Totem",
83+
)),
84+
expectError: false,
85+
},
6886
}
6987

7088
for _, tt := range tests {

cmd/pokemon.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package cmd
33
import (
44
"flag"
55
"fmt"
6+
"github.com/charmbracelet/lipgloss"
67
"github.com/digitalghost-dev/poke-cli/connections"
78
"github.com/digitalghost-dev/poke-cli/flags"
89
"github.com/digitalghost-dev/poke-cli/styling"
@@ -96,9 +97,13 @@ func PokemonCommand() {
9697
inches = 0
9798
}
9899

100+
coloredBullet := lipgloss.NewStyle().
101+
SetString("•").
102+
Foreground(lipgloss.Color("#FFCC00"))
103+
99104
fmt.Printf(
100-
"Your selected Pokémon: %s\nNational Pokédex #: %d\nWeight: %.1fkg (%.1f lbs)\nHeight: %.1fm (%d′%02d″)\n",
101-
capitalizedString, pokemonID, weightKilograms, weightPounds, heightFeet, feet, inches,
105+
"Your selected Pokémon: %s\n%s National Pokédex #: %d\n%s Weight: %.1fkg (%.1f lbs)\n%s Height: %.1fm (%d′%02d″)\n",
106+
capitalizedString, coloredBullet, pokemonID, coloredBullet, weightKilograms, weightPounds, coloredBullet, heightFeet, feet, inches,
102107
)
103108

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

cmd/pokemon_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,5 +78,5 @@ func TestPokemonCommand(t *testing.T) {
7878
}
7979

8080
// Assert output contains expected Pokémon details
81-
assert.Equal(t, output.String(), "Your selected Pokémon: Bulbasaur\nNational Pokédex #: 1\nWeight: 6.9kg (15.2 lbs)\nHeight: 2.3m (2′04″)\n")
81+
assert.Equal(t, output.String(), "Your selected Pokémon: Bulbasaur\n• National Pokédex #: 1\n• Weight: 6.9kg (15.2 lbs)\n• Height: 2.3m (2′04″)\n")
8282
}

cmd/validateargs.go

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ func ValidatePokemonArgs(args []string) error {
6464
if len(args) < 3 {
6565
errMessage := styling.ErrorBorder.Render(
6666
styling.ErrorColor.Render("Error!"),
67-
"\nPlease declare a Pokémon's name after the [pokemon] command",
67+
"\nPlease declare a Pokémon's name after the <pokemon> command",
6868
"\nRun 'poke-cli pokemon -h' for more details",
6969
"\nerror: insufficient arguments",
7070
)
@@ -109,21 +109,11 @@ func ValidatePokemonArgs(args []string) error {
109109
}
110110
}
111111

112-
// Add a check for invalid Pokémon names (e.g., names starting with `-`)
113-
if len(args[2]) > 0 && args[2][0] == '-' {
114-
errMessage := styling.ErrorBorder.Render(
115-
styling.ErrorColor.Render("Error!"),
116-
"\nPokémon not found. Perhaps a typo in the name?",
117-
)
118-
return fmt.Errorf("%s", errMessage)
119-
}
120-
121112
return nil
122113
}
123114

124115
// ValidateTypesArgs validates the command line arguments
125116
func ValidateTypesArgs(args []string) error {
126-
127117
handleHelpFlag(args)
128118

129119
if len(args) > 3 {

0 commit comments

Comments
 (0)