Skip to content
Merged

1.9.4 #273

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 @@ -31,7 +31,7 @@ on:
- main

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

Expand Down
2 changes: 1 addition & 1 deletion .goreleaser.yml
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.9.3
- -s -w -X main.version=v1.9.4

archives:
- formats: [ 'zip' ]
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.9.3" -o poke-cli .
RUN go build -ldflags "-X main.version=v1.9.4" -o poke-cli .

# build 2
FROM --platform=$BUILDPLATFORM alpine:3.23
Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<img width="425" src="poke-cli.png" alt="pokemon-logo"/>
<h4></h4>
<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.9.3?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.9.4?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 @@ -99,11 +99,11 @@ Cloudsmith is a fully cloud-based service that lets you easily create, store, an
3. Choose how to interact with the container:
* Run a single command and exit:
```bash
docker run --rm -it digitalghostdev/poke-cli:v1.9.3 <command> [subcommand] [flag]
docker run --rm -it digitalghostdev/poke-cli:v1.9.4 <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.9.3 -c "cd /app && exec sh"
docker run --rm -it --name poke-cli --entrypoint /bin/sh digitalghostdev/poke-cli:v1.9.4 -c "cd /app && exec sh"
# placed into the /app directory, run the program with './poke-cli'
# example: ./poke-cli ability swift-swim
```
Expand All @@ -112,13 +112,13 @@ Cloudsmith is a fully cloud-based service that lets you easily create, store, an
> The `card` command renders TCG card images using your terminal's graphics protocol. When running inside Docker, pass your terminal's environment variables so image rendering works correctly:
> ```bash
> # Kitty
> docker run --rm -it -e TERM -e KITTY_WINDOW_ID digitalghostdev/poke-cli:v1.9.3 card
> docker run --rm -it -e TERM -e KITTY_WINDOW_ID digitalghostdev/poke-cli:v1.9.4 card
>
> # WezTerm, iTerm2, Ghostty, Konsole, Rio, Tabby
> docker run --rm -it -e TERM -e TERM_PROGRAM digitalghostdev/poke-cli:v1.9.3 card
> docker run --rm -it -e TERM -e TERM_PROGRAM digitalghostdev/poke-cli:v1.9.4 card
>
> # Windows Terminal (Sixel)
> docker run --rm -it -e WT_SESSION digitalghostdev/poke-cli:v1.9.3 card
> docker run --rm -it -e WT_SESSION digitalghostdev/poke-cli:v1.9.4 card
> ```
> If your terminal is not listed above, image rendering is not supported inside Docker.

Expand Down
5 changes: 3 additions & 2 deletions card_data/pipelines/defs/extract/tcgcsv/extract_pricing.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,14 +137,15 @@ def pull_product_information(set_number: str) -> pl.DataFrame:
print(colored(" →", "blue"), f"Processing set: {set_number}")

product_id = SET_PRODUCT_MATCHING[set_number]
headers = {"User-Agent": "poke-cli/1.9"}
Comment thread
digitalghost-dev marked this conversation as resolved.

# Fetch product data
products_url = f"https://tcgcsv.com/tcgplayer/3/{product_id}/products"
products_data = requests.get(products_url, timeout=30).json()
products_data = requests.get(products_url, timeout=30, headers=headers).json()

# Fetch pricing data
prices_url = f"https://tcgcsv.com/tcgplayer/3/{product_id}/prices"
prices_data = requests.get(prices_url, timeout=30).json()
prices_data = requests.get(prices_url, timeout=30, headers=headers).json()

price_dict = {
price["productId"]: price.get("marketPrice")
Expand Down
2 changes: 1 addition & 1 deletion card_data/pipelines/poke_cli_dbt/dbt_project.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: 'poke_cli_dbt'
version: '1.9.3'
version: '1.9.4'

profile: 'poke_cli_dbt'

Expand Down
3 changes: 2 additions & 1 deletion cmd/item/item.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"charm.land/lipgloss/v2"
"github.com/digitalghost-dev/poke-cli/cmd/utils"
"github.com/digitalghost-dev/poke-cli/connections"
"github.com/digitalghost-dev/poke-cli/constants"
"github.com/digitalghost-dev/poke-cli/structs"
"github.com/digitalghost-dev/poke-cli/styling"
)
Expand Down Expand Up @@ -78,7 +79,7 @@ func itemInfoContainer(output *strings.Builder, itemStruct structs.ItemJSONStruc
fullDoc = lipgloss.JoinVertical(lipgloss.Top, capitalizedItem, itemCost, itemCategory, "---", "Description:", missingData)
} else {
for _, entry := range itemStruct.FlavorTextEntries {
if entry.Language.Name == "en" && entry.VersionGroup.Name == "sword-shield" {
if entry.Language.Name == "en" && entry.VersionGroup.Name == constants.VersionSwordShield {
if entry.Text != "" {
flavorTextEntry = entry.Text
fullDoc = lipgloss.JoinVertical(lipgloss.Top, capitalizedItem, itemCost, itemCategory, "---", "Description:", flavorTextEntry)
Expand Down
5 changes: 3 additions & 2 deletions cmd/move/move.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"charm.land/lipgloss/v2"
"github.com/digitalghost-dev/poke-cli/cmd/utils"
"github.com/digitalghost-dev/poke-cli/connections"
"github.com/digitalghost-dev/poke-cli/constants"
"github.com/digitalghost-dev/poke-cli/structs"
"github.com/digitalghost-dev/poke-cli/styling"
"golang.org/x/text/cases"
Expand Down Expand Up @@ -110,12 +111,12 @@ func moveEffectContainer(output *strings.Builder, moveStruct structs.MoveJSONStr
continue
}

if entry.VersionGroup.Name == "scarlet-violet" {
if entry.VersionGroup.Name == constants.VersionScarletViolet {
sv = entry.FlavorText
break
}

if entry.VersionGroup.Name == "sword-shield" {
if entry.VersionGroup.Name == constants.VersionSwordShield {
swsh = entry.FlavorText
}
}
Expand Down
161 changes: 6 additions & 155 deletions cmd/pokemon/pokemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,13 @@ import (
"flag"
"fmt"
"io"
"math"
"os"
"sort"
"strings"

"charm.land/lipgloss/v2"
"github.com/digitalghost-dev/poke-cli/cmd/utils"
"github.com/digitalghost-dev/poke-cli/connections"
"github.com/digitalghost-dev/poke-cli/flags"
"github.com/digitalghost-dev/poke-cli/styling"
"golang.org/x/text/cases"
"golang.org/x/text/language"
)

// PokemonCommand processes the Pokémon command
Expand Down Expand Up @@ -83,150 +78,6 @@ func PokemonCommand() (string, error) {

capitalizedString := styling.CapitalizeResourceName(pokemonName)

entry := func(w io.Writer) {
for _, entry := range pokemonSpeciesStruct.FlavorTextEntries {
if entry.Language.Name == "en" && (entry.Version.Name == "x" || entry.Version.Name == "shield" || entry.Version.Name == "scarlet") {
flavorText := strings.ReplaceAll(entry.FlavorText, "\n", " ")
flavorText = strings.Join(strings.Fields(flavorText), " ")

wrapped := utils.WrapText(flavorText, 60)
fmt.Fprintln(w, wrapped)
return
}
}
}

eggInformation := func(w io.Writer) {
var eggInformationSlice []string

modernEggInformationNames := map[string]string{
"indeterminate": "Amorphous",
"ground": "Field",
"humanshape": "Human-Like",
"plant": "Grass",
"no-eggs": "Undiscovered",
}

for _, entry := range pokemonSpeciesStruct.EggGroups {
if name, exists := modernEggInformationNames[entry.Name]; exists {
eggInformationSlice = append(eggInformationSlice, name)
} else {
eggInformationSlice = append(eggInformationSlice, cases.Title(language.English).String(entry.Name))
}
}

sort.Strings(eggInformationSlice)

genderRate := pokemonSpeciesStruct.GenderRate
m := map[int]string{
-1: "Genderless",
0: "0% F",
1: "12.5% F",
2: "25% F",
3: "37.5% F",
4: "50% F",
5: "62.5% F",
6: "75% F",
7: "87.5% F",
8: "100% F",
}

hatchCounter := pokemonSpeciesStruct.HatchCounter

fmt.Fprintf(w,
"\n%s %s %s\n%s %s %s\n%s %s %d",
styling.ColoredBullet,
"Egg Group(s):", strings.Join(eggInformationSlice, ", "),
styling.ColoredBullet,
"Gender Rate:", m[genderRate],
styling.ColoredBullet,
"Egg Cycles:", hatchCounter,
)
}

effortValues := func(w io.Writer) {
nameMapping := map[string]string{
"hp": "HP",
"attack": "Atk",
"defense": "Def",
"special-attack": "SpA",
"special-defense": "SpD",
"speed": "Spd",
}

var evs []string

for _, effortValue := range pokemonStruct.Stats {
if effortValue.Effort > 0 {
name, ok := nameMapping[effortValue.Stat.Name]
if !ok {
name = "Missing from API"
}
evs = append(evs, fmt.Sprintf("%d %s", effortValue.Effort, name))
}
}

fmt.Fprintf(w, "\n%s Effort Values: %s", styling.ColoredBullet, strings.Join(evs, ", "))
}

typing := func(w io.Writer) {
var typeBoxes []string

for _, pokeType := range pokemonStruct.Types {
colorHex, exists := styling.ColorMap[pokeType.Type.Name]
if exists {
color := lipgloss.Color(colorHex)
typeColorStyle := lipgloss.NewStyle().
Align(lipgloss.Center).
Foreground(lipgloss.Color("#FAFAFA")).
Background(color).
Margin(1, 1, 0, 0).
Height(1).
Width(14)

rendered := typeColorStyle.Render(cases.Title(language.English).String(pokeType.Type.Name))
typeBoxes = append(typeBoxes, rendered)
}
}

joinedTypes := lipgloss.JoinHorizontal(lipgloss.Top, typeBoxes...)
fmt.Fprintln(w, joinedTypes)
}

metrics := func(w io.Writer) {
// Weight calculation
weightKilograms := float64(pokemonStruct.Weight) / 10
weightPounds := float64(weightKilograms) * 2.20462

// Height calculation
heightMeters := float64(pokemonStruct.Height) / 10
heightFeet := heightMeters * 3.28084
feet := int(heightFeet)
inches := int(math.Round((heightFeet - float64(feet)) * 12)) // Use math.Round to avoid truncation

// Adjust for rounding to 12 inches (carry over to the next foot)
if inches == 12 {
feet++
inches = 0
}

fmt.Fprintf(w, "\n%s National Pokédex #: %d\n%s Weight: %.1fkg (%.1f lbs)\n%s Height: %.1fm (%d′%02d″)\n",
styling.ColoredBullet, pokemonStruct.ID,
styling.ColoredBullet, weightKilograms, weightPounds,
styling.ColoredBullet, heightMeters, feet, inches)
}

species := func(w io.Writer) {
if pokemonSpeciesStruct.EvolvesFromSpecies.Name != "" {
evolvesFrom := pokemonSpeciesStruct.EvolvesFromSpecies.Name

capitalizedPokemonName := styling.CapitalizeResourceName(evolvesFrom)
fmt.Fprintf(w, "%s %s %s", styling.ColoredBullet, "Evolves from:", capitalizedPokemonName)
} else {
fmt.Fprintf(w, "%s %s", styling.ColoredBullet, "Basic Pokémon")
}
}

var (
entryOutput bytes.Buffer
eggGroupOutput bytes.Buffer
Expand All @@ -236,12 +87,12 @@ func PokemonCommand() (string, error) {
effortValuesOutput bytes.Buffer
)

entry(&entryOutput)
eggInformation(&eggGroupOutput)
typing(&typeOutput)
metrics(&metricsOutput)
species(&speciesOutput)
effortValues(&effortValuesOutput)
renderEntry(&entryOutput, pokemonSpeciesStruct)
renderEggInformation(&eggGroupOutput, pokemonSpeciesStruct)
renderTyping(&typeOutput, pokemonStruct)
renderMetrics(&metricsOutput, pokemonStruct)
renderSpecies(&speciesOutput, pokemonSpeciesStruct)
renderEffortValues(&effortValuesOutput, pokemonStruct)

fmt.Fprintf(&output,
"Your selected Pokémon: %s\n%s\n%s%s%s%s%s\n",
Expand Down
Loading
Loading