Skip to content
Merged

1.3.2 #154

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ on:
- main

env:
VERSION_NUMBER: 'v1.3.1'
VERSION_NUMBER: 'v1.3.2'
DOCKERHUB_REGISTRY_NAME: 'digitalghostdev/poke-cli'
AWS_REGION: 'us-west-2'

Expand Down
2 changes: 1 addition & 1 deletion .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ builds:
- windows
- darwin
ldflags:
- -s -w -X main.version=v1.3.1
- -s -w -X main.version=v1.3.2

archives:
- format: tar.gz
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ RUN go mod download

COPY . .

RUN go build -ldflags "-X main.version=v1.3.1" -o poke-cli .
RUN go build -ldflags "-X main.version=v1.3.2" -o poke-cli .

# build 2
FROM --platform=$BUILDPLATFORM alpine:latest
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<img height="250" width="350" src="pokemon.svg" alt="pokemon-logo"/>
<h1>Pokémon CLI</h1>
<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">
<img src="https://img.shields.io/docker/image-size/digitalghostdev/poke-cli/v1.3.1?arch=arm64&style=flat-square&logo=docker&logoColor=FFCC00&labelColor=EEE&color=FFCC00" alt="docker-image-size">
<img src="https://img.shields.io/docker/image-size/digitalghostdev/poke-cli/v1.3.2?arch=arm64&style=flat-square&logo=docker&logoColor=FFCC00&labelColor=EEE&color=FFCC00" alt="docker-image-size">
<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">
</div>
<div align="center">
Expand Down Expand Up @@ -76,11 +76,11 @@ View future plans in the [Roadmap](#roadmap) section.
3. Choose how to interact with the container:
* Run a single command and exit:
```bash
docker run --rm -it digitalghostdev/poke-cli:v1.3.1 <command> [subcommand] flag]
docker run --rm -it digitalghostdev/poke-cli:v1.3.2 <command> [subcommand] flag]
```
* Enter the container and use its shell:
```bash
docker run --rm -it --name poke-cli --entrypoint /bin/sh digitalghostdev/poke-cli:v1.3.1 -c "cd /app && exec sh"
docker run --rm -it --name poke-cli --entrypoint /bin/sh digitalghostdev/poke-cli:v1.3.2 -c "cd /app && exec sh"
# placed into the /app directory, run the program with './poke-cli'
# example: ./poke-cli ability swift-swim
```
Expand Down
74 changes: 55 additions & 19 deletions flags/pokemonflagset.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"sort"
"strconv"
"strings"
"sync"
)

func header(header string) string {
Expand Down Expand Up @@ -225,37 +226,72 @@

var moves []MoveInfo

movesChan := make(chan MoveInfo)
errorsChan := make(chan error)

var wg sync.WaitGroup

// Count eligible moves for concurrency
eligibleMoves := 0

Check warning on line 235 in flags/pokemonflagset.go

View check run for this annotation

Codecov / codecov/patch

flags/pokemonflagset.go#L229-L235

Added lines #L229 - L235 were not covered by tests
for _, pokeMove := range pokemonStruct.Moves {
for _, detail := range pokeMove.VersionGroupDetails {
if detail.VersionGroup.Name != "scarlet-violet" || detail.MoveLearnedMethod.Name != "level-up" {
continue
}

moveName := pokeMove.Move.Name
moveStruct, _, err := connections.MoveApiCall("move", moveName, baseURL)
if err != nil {
log.Printf("Error fetching move %s: %v", moveName, err)
eligibleMoves++
wg.Add(1)
go func(moveName string, level int) {
defer wg.Done()

moveStruct, _, err := connections.MoveApiCall("move", moveName, baseURL)
if err != nil {
errorsChan <- fmt.Errorf("error fetching move %s: %v", moveName, err)
return
}

Check warning on line 251 in flags/pokemonflagset.go

View check run for this annotation

Codecov / codecov/patch

flags/pokemonflagset.go#L242-L251

Added lines #L242 - L251 were not covered by tests

capitalizedMove := cases.Title(language.English).String(strings.ReplaceAll(moveName, "-", " "))
capitalizedType := cases.Title(language.English).String(moveStruct.Type.Name)

movesChan <- MoveInfo{
Accuracy: moveStruct.Accuracy,
Level: level,
Name: capitalizedMove,
Power: moveStruct.Power,
Type: capitalizedType,
}

Check warning on line 262 in flags/pokemonflagset.go

View check run for this annotation

Codecov / codecov/patch

flags/pokemonflagset.go#L253-L262

Added lines #L253 - L262 were not covered by tests
}(pokeMove.Move.Name, detail.LevelLearnedAt)
}
}

// Close channels when all goroutines are done
go func() {
wg.Wait()
close(movesChan)
close(errorsChan)
}()

Check warning on line 272 in flags/pokemonflagset.go

View check run for this annotation

Codecov / codecov/patch

flags/pokemonflagset.go#L268-L272

Added lines #L268 - L272 were not covered by tests

// Collect results from channels
movesOpen, errorsOpen := true, true
for movesOpen || errorsOpen {
select {
case move, ok := <-movesChan:
if !ok {
movesOpen = false

Check warning on line 280 in flags/pokemonflagset.go

View check run for this annotation

Codecov / codecov/patch

flags/pokemonflagset.go#L275-L280

Added lines #L275 - L280 were not covered by tests
continue
}

capitalizedMove := cases.Title(language.English).String(strings.ReplaceAll(moveName, "-", " "))
capitalizedType := cases.Title(language.English).String(moveStruct.Type.Name)

moves = append(moves, MoveInfo{
Accuracy: moveStruct.Accuracy,
Level: detail.LevelLearnedAt,
Name: capitalizedMove,
Power: moveStruct.Power,
Type: capitalizedType,
})
moves = append(moves, move)
case err, ok := <-errorsChan:
if !ok {
errorsOpen = false
continue

Check warning on line 287 in flags/pokemonflagset.go

View check run for this annotation

Codecov / codecov/patch

flags/pokemonflagset.go#L283-L287

Added lines #L283 - L287 were not covered by tests
}
log.Println(err)

Check warning on line 289 in flags/pokemonflagset.go

View check run for this annotation

Codecov / codecov/patch

flags/pokemonflagset.go#L289

Added line #L289 was not covered by tests
}
}

if len(moves) == 0 {
_, err := fmt.Fprintln(w, "No level-up moves found for Scarlet & Violet.")
if err != nil {
return err
}
fmt.Fprintln(w, "No level-up moves found for Scarlet & Violet.")

Check warning on line 294 in flags/pokemonflagset.go

View check run for this annotation

Codecov / codecov/patch

flags/pokemonflagset.go#L294

Added line #L294 was not covered by tests
return nil
}

Expand Down