Skip to content
Merged

1.5.1 #172

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
5 changes: 4 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,7 @@ go.work.sum
dist/

# testdata
testdata/
testdata/

# Python data
card_data/
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ on:
- main

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

Expand Down
10 changes: 5 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ card_data/.venv
__pycache__/

# Terraform
card_data/terraform/access-token
/card_data/terraform/access-token
card_data/terraform/secrets.tfvars
card_data/terraform/terraform.tfstate
/card_data/terraform/.terraform/
card_data/infra/access-token
/card_data/infra/access-token
card_data/infra/secrets.tfvars
card_data/infra/terraform.tfstate
/card_data/infra/.terraform/
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.5.0
- -s -w -X main.version=v1.5.1

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.5.0" -o poke-cli .
RUN go build -ldflags "-X main.version=v1.5.1" -o poke-cli .

# build 2
FROM --platform=$BUILDPLATFORM alpine:3.22
Expand Down
33 changes: 17 additions & 16 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.5.0?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.5.1?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 All @@ -24,7 +24,7 @@ View future plans in the [Roadmap](#roadmap) section.

---
## Demo
![demo](https://poke-cli-s3-bucket.s3.us-west-2.amazonaws.com/demo-v1.5.0.gif)
![demo](https://poke-cli-s3-bucket.s3.us-west-2.amazonaws.com/demo-v1.5.1.gif)

---
## Installation
Expand Down Expand Up @@ -78,11 +78,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.5.0 <command> [subcommand] flag]
docker run --rm -it digitalghostdev/poke-cli:v1.5.1 <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.5.0 -c "cd /app && exec sh"
docker run --rm -it --name poke-cli --entrypoint /bin/sh digitalghostdev/poke-cli:v1.5.1 -c "cd /app && exec sh"
# placed into the /app directory, run the program with './poke-cli'
# example: ./poke-cli ability swift-swim
```
Expand Down Expand Up @@ -118,7 +118,7 @@ View future plans in the [Roadmap](#roadmap) section.

---
## Usage
By running `poke-cli [-h | --help]`, it'll display information on how to use the tool.
By running `poke-cli [-h | --help]`, it'll display information on how to use the tool or check out the [docs](https://docs.poke-cli.com/)!
```
╭───────────────────────────────────────────────────────────────╮
│Welcome! This tool displays data related to Pokémon! │
Expand Down Expand Up @@ -166,9 +166,9 @@ Below is a list of the planned/completed commands and flags:
- [x] `natures`: get data about natures.
- [x] `pokemon`: get data about a Pokémon.
- [x] `-a | --abilities`: display the Pokémon's abilities.
- [ ] `-d | --defense`: display the Pokémon's type defences.
- [x] `-i | --image`: display a pixel image of the Pokémon.
- [x] `-s | --stats`: display the Pokémon's base stats.
- [x] `-t | --types`: display the Pokémon's typing.
- [x] `-m | --moves`: display learnable moves.
- [ ] `search`: search for a resource
- [x] `ability`
Expand All @@ -181,13 +181,14 @@ Below is a list of the planned/completed commands and flags:

---
## Tested Terminals
| OS | Terminal | Status | Issues |
|---------|-------------------|:------:|-------------------------------|
| macOS | Ghostty | ✅ | None |
| macOS | Alacritty | ✅ | None |
| macOS | HyperJS | ✅ | None |
| macOS | iTerm2 | ✅ | None |
| macOS | macOS Terminal | ⚠️ | Images do not render properly |
| Windows | Windows Terminal | ✅ | None |
| Ubuntu | Standard Terminal | ✅ | None |
| Ubuntu | Tabby | ✅ | None |
| Terminal | OS | Status | Issues |
|------------------|:-------------------------:|:------:|-----------------------------------------|
| Alacritty | macOS, Ubuntu,<br>Windows | ✅ | None |
| Ghostty | macOS | ✅ | None |
| HyperJS | macOS | ✅ | None |
| iTerm2 | macOS | ✅ | None |
| Linux Terminal | Ubuntu | ✅ | None |
| macOS Terminal | macOS | ⚠️ | `pokemon [name] --image=xx` flag issues |
| Tabby | Ubuntu | ✅ | None |
| WezTerm | macOS, Windows | ✅ | None |
| Windows Terminal | Windows | ✅ | None |
2 changes: 1 addition & 1 deletion cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ func runCLI(args []string) int {
return cmdFunc()
default:
errMessage := styling.ErrorBorder.Render(
styling.ErrorColor.Render("Error!"),
styling.ErrorColor.Render("Error!"),
fmt.Sprintf("\n\t%-15s", fmt.Sprintf("'%s' is not a valid command.\n", cmdArg)),
styling.StyleBold.Render("\nCommands:"),
fmt.Sprintf("\n\t%-15s %s", "ability", "Get details about an ability"),
Expand Down
40 changes: 36 additions & 4 deletions cmd/pokemon/pokemon.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
package pokemon

import (
"bytes"
"flag"
"fmt"
"github.com/charmbracelet/lipgloss"
"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"
"io"
"math"
"os"
"strings"
Expand All @@ -21,6 +24,7 @@ func PokemonCommand() (string, error) {
hintMessage := styling.StyleItalic.Render("options: [sm, md, lg]")

flag.Usage = func() {
styledFlag := styling.ErrorColor.Render(fmt.Sprintf("%-30s", "-t, --types"))
helpMessage := styling.HelpBorder.Render(
"Get details about a specific Pokémon.\n\n",
styling.StyleBold.Render("USAGE:"),
Expand All @@ -33,7 +37,7 @@ func PokemonCommand() (string, error) {
fmt.Sprintf("\n\t%5s%-15s", "", hintMessage),
fmt.Sprintf("\n\t%-30s %s", "-m, --moves", "Prints the Pokemon's learnable moves."),
fmt.Sprintf("\n\t%-30s %s", "-s, --stats", "Prints the Pokémon's base stats."),
fmt.Sprintf("\n\t%-30s %s", "-t, --types", "Prints the Pokémon's typing."),
fmt.Sprintf("\n\t%s %s", styledFlag, styling.ErrorColor.Render("Deprecated. Types are included with each Pokémon.")),
fmt.Sprintf("\n\t%-30s %s", "-h, --help", "Prints the help menu."),
)
output.WriteString(helpMessage)
Expand Down Expand Up @@ -88,11 +92,39 @@ func PokemonCommand() (string, error) {
inches = 0
}

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)
}

var typeOutput bytes.Buffer
typing(&typeOutput)

output.WriteString(fmt.Sprintf(
"Your selected Pokémon: %s\n%s National Pokédex #: %d\n%s Weight: %.1fkg (%.1f lbs)\n%s Height: %.1fm (%d′%02d″)\n",
capitalizedString, styling.ColoredBullet, pokemonStruct.ID,
"Your selected Pokémon: %s\n%s\n%s National Pokédex #: %d\n%s Weight: %.1fkg (%.1f lbs)\n%s Height: %.1fm (%d′%02d″)\n",
capitalizedString, typeOutput.String(),
styling.ColoredBullet, pokemonStruct.ID,
styling.ColoredBullet, weightKilograms, weightPounds,
styling.ColoredBullet, heightFeet, feet, inches,
styling.ColoredBullet, heightMeters, feet, inches,
))

if *imageFlag != "" || *shortImageFlag != "" {
Expand Down
11 changes: 6 additions & 5 deletions cmd/pokemon/pokemon_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ func TestPokemonCommand(t *testing.T) {
args: []string{"pokemon", "--help"},
expectedOutput: utils.LoadGolden(t, "pokemon_help.golden"),
},
{
name: "Pokemon no flags with dual type",
args: []string{"pokemon", "victini"},
expectedOutput: utils.LoadGolden(t, "pokemon_no_flags_dual_type.golden"),
expectedError: true,
},
{
name: "Pokemon abilities flag",
args: []string{"pokemon", "metagross", "--abilities"},
Expand Down Expand Up @@ -65,11 +71,6 @@ func TestPokemonCommand(t *testing.T) {
args: []string{"pokemon", "toxicroak", "--stats"},
expectedOutput: utils.LoadGolden(t, "pokemon_stats.golden"),
},
{
name: "Pokemon typed flags",
args: []string{"pokemon", "armarouge", "--types"},
expectedOutput: utils.LoadGolden(t, "pokemon_types.golden"),
},
}

for _, tt := range tests {
Expand Down
2 changes: 1 addition & 1 deletion cmd/search/model_input.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func UpdateInput(msg tea.Msg, m Model) (tea.Model, tea.Cmd) {

// checking for blank queries
if strings.TrimSpace(searchTerm) == "" {
errMessage := styling.ErrorBorder.Render(styling.ErrorColor.Render("Error!"), "\nNo blank queries")
errMessage := styling.ErrorBorder.Render(styling.ErrorColor.Render("Error!"), "\nNo blank queries")
m.WarningMessage = errMessage
return m, nil
}
Expand Down
18 changes: 9 additions & 9 deletions cmd/utils/validateargs.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
func checkLength(args []string, max int) error {
if len(args) > max {
errMessage := styling.ErrorBorder.Render(
styling.ErrorColor.Render("Error!") + "\nToo many arguments",
styling.ErrorColor.Render("Error!") + "\nToo many arguments",
)
return fmt.Errorf("%s", errMessage)
}
Expand All @@ -20,7 +20,7 @@ func checkLength(args []string, max int) error {
// checkNoOtherOptions checks if there are exactly 3 arguments and the third argument is neither '-h' nor '--help'
func checkNoOtherOptions(args []string, max int, commandName string) error {
if len(args) == max && args[2] != "-h" && args[2] != "--help" {
errMsg := styling.ErrorColor.Render("Error!") +
errMsg := styling.ErrorColor.Render("Error!") +
"\nThe only available options after the\n" + commandName + " command are '-h' or '--help'"
return fmt.Errorf("%s", styling.ErrorBorder.Render(errMsg))
}
Expand All @@ -34,7 +34,7 @@ func ValidateAbilityArgs(args []string) error {
}

if len(args) == 2 {
errMessage := styling.ErrorBorder.Render(styling.ErrorColor.Render("Error!"), "\nPlease specify an ability")
errMessage := styling.ErrorBorder.Render(styling.ErrorColor.Render("Error!"), "\nPlease specify an ability")
return fmt.Errorf("%s", errMessage)
}

Expand All @@ -48,7 +48,7 @@ func ValidateItemArgs(args []string) error {
}

if len(args) == 2 {
errMessage := styling.ErrorBorder.Render(styling.ErrorColor.Render("Error!"), "\nPlease specify an item ")
errMessage := styling.ErrorBorder.Render(styling.ErrorColor.Render("Error!"), "\nPlease specify an item ")
return fmt.Errorf("%s", errMessage)
}

Expand All @@ -62,7 +62,7 @@ func ValidateMoveArgs(args []string) error {
}

if len(args) == 2 {
errMessage := styling.ErrorBorder.Render(styling.ErrorColor.Render("Error!"), "\nPlease specify a move ")
errMessage := styling.ErrorBorder.Render(styling.ErrorColor.Render("Error!"), "\nPlease specify a move ")
return fmt.Errorf("%s", errMessage)
}

Expand All @@ -87,7 +87,7 @@ func ValidatePokemonArgs(args []string) error {
// Check if the number of arguments is less than 3
if len(args) < 3 {
errMessage := styling.ErrorBorder.Render(
styling.ErrorColor.Render("Error!"),
styling.ErrorColor.Render("Error!"),
"\nPlease declare a Pokémon's name after the <pokemon> command",
"\nRun 'poke-cli pokemon -h' for more details",
"\nerror: insufficient arguments",
Expand All @@ -101,7 +101,7 @@ func ValidatePokemonArgs(args []string) error {

printImageFlagError := func() error {
msg := styling.ErrorBorder.Render(
styling.ErrorColor.Render("Error!") +
styling.ErrorColor.Render("Error!") +
"\nThe image flag (-i or --image) requires a non-empty value.\nValid sizes are: lg, md, sm.",
)
return fmt.Errorf("%s", msg)
Expand All @@ -123,7 +123,7 @@ func ValidatePokemonArgs(args []string) error {
for _, arg := range args[3:] {
// Check for an empty flag after Pokémon's name
if arg == "-" || arg == "--" {
errorTitle := styling.ErrorColor.Render("Error!")
errorTitle := styling.ErrorColor.Render("Error!")
errorString := fmt.Sprintf(
"\nEmpty flag '%s'.\nPlease specify valid flag(s).",
arg,
Expand All @@ -135,7 +135,7 @@ func ValidatePokemonArgs(args []string) error {

// Check if the argument after Pokémon's name is an attempted flag
if arg[0] != '-' {
errorTitle := styling.ErrorColor.Render("Error!")
errorTitle := styling.ErrorColor.Render("Error!")
errorString := fmt.Sprintf(
"\nInvalid argument '%s'.\nOnly flags are allowed after declaring a Pokémon's name",
arg,
Expand Down
8 changes: 4 additions & 4 deletions cmd/utils/validateargs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func TestValidateAbilityArgs(t *testing.T) {
{"poke-cli", "ability", "strong-jaw", "all", "pokemon"},
}

expectedError := styling.StripANSI("╭──────────────────╮\n│Error! │\n│Too many arguments│\n╰──────────────────╯")
expectedError := styling.StripANSI("╭──────────────────╮\n│Error! │\n│Too many arguments│\n╰──────────────────╯")

for _, input := range tooManyArgs {
err := ValidateAbilityArgs(input)
Expand Down Expand Up @@ -168,7 +168,7 @@ func TestValidatePokemonArgs(t *testing.T) {
{"poke-cli", "pokemon", "hypo", "--abilities", "-s", "--types", "--image=sm", "-m", "-p"},
}

expectedError := styling.StripANSI("╭──────────────────╮\n│Error! │\n│Too many arguments│\n╰──────────────────╯")
expectedError := styling.StripANSI("╭──────────────────╮\n│Error! │\n│Too many arguments│\n╰──────────────────╯")

for _, input := range tooManyArgs {
err := ValidatePokemonArgs(input)
Expand Down Expand Up @@ -207,7 +207,7 @@ func TestValidateSearchArgs(t *testing.T) {
{"poke-cli", "search", "pokemon", "meowscarada"},
}

expectedError := styling.StripANSI("╭──────────────────╮\n│Error! │\n│Too many arguments│\n╰──────────────────╯")
expectedError := styling.StripANSI("╭──────────────────╮\n│Error! │\n│Too many arguments│\n╰──────────────────╯")

for _, input := range tooManyArgs {
err := ValidateSearchArgs(input)
Expand Down Expand Up @@ -249,7 +249,7 @@ func TestValidateTypesArgs(t *testing.T) {
{"poke-cli", "types", "rock", "pokemon"},
}

expectedError := styling.StripANSI("╭──────────────────╮\n│Error! │\n│Too many arguments│\n╰──────────────────╯")
expectedError := styling.StripANSI("╭──────────────────╮\n│Error! │\n│Too many arguments│\n╰──────────────────╯")

for _, input := range tooManyArgs {
err := ValidateTypesArgs(input)
Expand Down
Loading