Skip to content
Merged
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.8.9'
VERSION_NUMBER: 'v1.8.10'
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.8.9
- -s -w -X main.version=v1.8.10

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

# build 2
FROM --platform=$BUILDPLATFORM alpine:3.23
Expand Down
8 changes: 4 additions & 4 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.8.9?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.8.10?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.8.9 <command> [subcommand] [flag]
docker run --rm -it digitalghostdev/poke-cli:v1.8.10 <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.8.9 -c "cd /app && exec sh"
docker run --rm -it --name poke-cli --entrypoint /bin/sh digitalghostdev/poke-cli:v1.8.10 -c "cd /app && exec sh"
# placed into the /app directory, run the program with './poke-cli'
# example: ./poke-cli ability swift-swim
```
Expand All @@ -118,7 +118,7 @@ Cloudsmith is a fully cloud-based service that lets you easily create, store, an
6. Run the tool!

> [!IMPORTANT]
> For macOS, you may have to allow the executable to run as it is not signed. Head to System Settings > Privacy & Security > scroll down and allow executable to run.
> For macOS, you may have to allow the executable to run as it is not signed. Head to System Settings > Privacy & Security > scroll down and allow the executable to run.

<details>

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.8.9'
version: '1.8.10'

profile: 'poke_cli_dbt'

Expand Down
2 changes: 1 addition & 1 deletion card_data/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "card-data"
version = "1.5.2"
version = "1.8.10"
description = "File directory to store all data related processes for the Pokémon TCG."
readme = "README.md"
requires-python = ">=3.12"
Expand Down
4 changes: 1 addition & 3 deletions cmd/ability/ability.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,7 @@ func AbilityCommand() (string, error) {
return output.String(), nil
}

flag.Parse()

if err := utils.ValidateAbilityArgs(args); err != nil {
if err := utils.ValidateArgs(args, utils.Validator{MaxArgs: 4, CmdName: "ability", RequireName: true, HasFlags: true}); err != nil {
output.WriteString(err.Error())
return output.String(), err
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/berry/berry.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func BerryCommand() (string, error) {
flag.Parse()

// Validate arguments
if err := utils.ValidateBerryArgs(os.Args); err != nil {
if err := utils.ValidateArgs(os.Args, utils.Validator{MaxArgs: 3, CmdName: "berry", RequireName: false, HasFlags: false}); err != nil {
output.WriteString(err.Error())
return output.String(), err
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/card/card.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func CardCommand() (string, error) {
flag.Parse()

// Validate arguments
if err := utils.ValidateCardArgs(os.Args); err != nil {
if err := utils.ValidateArgs(os.Args, utils.Validator{MaxArgs: 3, CmdName: "card", RequireName: false, HasFlags: false}); err != nil {
output.WriteString(err.Error())
return output.String(), err
}
Expand Down
23 changes: 16 additions & 7 deletions cmd/card/cardlist.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ var getCardData = connections.CallTCGData
type CardsModel struct {
AllRows []table.Row
Choice string
Error error
IllustratorMap map[string]string
ImageMap map[string]string
Loading bool
Expand Down Expand Up @@ -62,7 +63,7 @@ func cardTableStyles(selectedBg lipgloss.Color) table.Styles {
return s
}

func (m *CardsModel) syncTableStylesForFocus() {
func syncTableStylesForFocus(m *CardsModel) {
if m.Search.Focused() {
m.TableStyles = cardTableStyles(inactiveTableSelectedBg)
} else {
Expand Down Expand Up @@ -146,7 +147,7 @@ func (m CardsModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
if m.Search.Focused() {
m.Search.Blur()
m.Table.Focus()
m.syncTableStylesForFocus()
syncTableStylesForFocus(&m)
return m, nil
}
m.Quitting = true
Expand All @@ -168,15 +169,16 @@ func (m CardsModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
m.Table.Blur()
m.Search.Focus()
}
m.syncTableStylesForFocus()
syncTableStylesForFocus(&m)
return m, nil
}

case cardDataMsg:
// Data arrived - stop loading and build the table
if msg.err != nil {
m.Quitting = true
return m, tea.Quit
m.Error = msg.err
m.Loading = false
return m, nil
}

ti := textinput.New()
Expand Down Expand Up @@ -219,7 +221,7 @@ func (m CardsModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
prev := m.Search.Value()
m.Search, bubbleCmd = m.Search.Update(msg)
if m.Search.Value() != prev {
m.applyFilter()
applyFilter(&m)
}
} else {
m.Table, bubbleCmd = m.Table.Update(msg)
Expand All @@ -237,7 +239,7 @@ func (m CardsModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
return m, bubbleCmd
}

func (m *CardsModel) applyFilter() {
func applyFilter(m *CardsModel) {
q := strings.TrimSpace(strings.ToLower(m.Search.Value()))
if q == "" {
m.Table.SetRows(m.AllRows)
Expand All @@ -263,6 +265,13 @@ func (m CardsModel) View() string {
if m.Quitting {
return "\n Quitting card search...\n\n"
}
if m.Error != nil {
return styling.ApiErrorStyle.Render(
"Error loading cards from Supabase:\n" +
m.Error.Error() + "\n\n" +
"Press ctrl+c or esc to exit.",
)
}
if m.Loading {
return lipgloss.NewStyle().Padding(2).Render(
m.Spinner.View() + " Loading cards...",
Expand Down
18 changes: 13 additions & 5 deletions cmd/card/cardlist_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ func TestCardDataMsg_PopulatesModel(t *testing.T) {
}
}

func TestCardDataMsg_Error_QuitsModel(t *testing.T) {
func TestCardDataMsg_Error_StoresError(t *testing.T) {
model, _ := CardsList("set123")

// Simulate receiving an error via cardDataMsg
Expand All @@ -362,12 +362,20 @@ func TestCardDataMsg_Error_QuitsModel(t *testing.T) {
newModel, cmd := model.Update(msg)
resultModel := newModel.(CardsModel)

if !resultModel.Quitting {
t.Error("Quitting should be true when error received")
if resultModel.Error == nil {
t.Error("Error should be set when error received")
}

if cmd == nil {
t.Error("Should return tea.Quit command on error")
if resultModel.Error.Error() != "network error" {
t.Errorf("Expected error message 'network error', got '%s'", resultModel.Error.Error())
}

if resultModel.Loading {
t.Error("Loading should be false after error")
}

if cmd != nil {
t.Error("Should not return a command on error (stays in view to show error)")
}
}

Expand Down
23 changes: 17 additions & 6 deletions cmd/card/setslist.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package card

import (
"encoding/json"
"fmt"

"github.com/charmbracelet/bubbles/list"
"github.com/charmbracelet/bubbles/spinner"
Expand All @@ -16,6 +15,7 @@ var getSetsData = connections.CallTCGData

type SetsModel struct {
Choice string
Error error
Loading bool
List list.Model
Quitting bool
Expand Down Expand Up @@ -79,6 +79,9 @@ func (m SetsModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
m.Quitting = true
return m, tea.Quit
case "enter":
if m.Error != nil {
return m, nil
}
i, ok := m.List.SelectedItem().(item)
if ok {
m.Choice = string(i)
Expand All @@ -90,15 +93,16 @@ func (m SetsModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
case setsDataMsg:
// Data arrived - stop loading and build the list
if msg.err != nil {
m.Quitting = true
return m, tea.Quit
m.Error = msg.err
m.Loading = false
return m, nil
}

const listWidth = 20
const listHeight = 20

l := list.New(msg.items, itemDelegate{}, listWidth, listHeight)
l.Title = fmt.Sprintf("Pick a set from the %s series", msg.seriesID)
l.Title = "Choose a set!"
l.SetShowStatusBar(false)
l.SetFilteringEnabled(false)
l.Styles.Title = titleStyle
Expand All @@ -116,14 +120,14 @@ func (m SetsModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
return m, cmd

case tea.WindowSizeMsg:
if !m.Loading {
if !m.Loading && m.Error == nil {
m.List.SetWidth(msg.Width)
}
return m, nil
}

// Only update the list if it's been initialized
if !m.Loading {
if !m.Loading && m.Error == nil {
var cmd tea.Cmd
m.List, cmd = m.List.Update(msg)
return m, cmd
Expand All @@ -132,6 +136,13 @@ func (m SetsModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
}

func (m SetsModel) View() string {
if m.Error != nil {
return styling.ApiErrorStyle.Render(
"Error loading sets from Supabase:\n" +
m.Error.Error() + "\n\n" +
"Press ctrl+c or esc to exit.",
)
}
if m.Choice != "" {
return quitTextStyle.Render("Set selected:", m.Choice)
}
Expand Down
18 changes: 13 additions & 5 deletions cmd/card/setslist_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ func TestSetsDataMsg_PopulatesModel(t *testing.T) {
}
}

func TestSetsDataMsg_Error_QuitsModel(t *testing.T) {
func TestSetsDataMsg_Error_StoresError(t *testing.T) {
model, _ := SetsList("sv")

// Simulate receiving an error via setsDataMsg
Expand All @@ -249,12 +249,20 @@ func TestSetsDataMsg_Error_QuitsModel(t *testing.T) {
newModel, cmd := model.Update(msg)
resultModel := newModel.(SetsModel)

if !resultModel.Quitting {
t.Error("Quitting should be true when error received")
if resultModel.Error == nil {
t.Error("Error should be set when error received")
}

if cmd == nil {
t.Error("Should return tea.Quit command on error")
if resultModel.Error.Error() != "network error" {
t.Errorf("Expected error message 'network error', got '%s'", resultModel.Error.Error())
}

if resultModel.Loading {
t.Error("Loading should be false after error")
}

if cmd != nil {
t.Error("Should not return a command on error (stays in view to show error)")
}
}

Expand Down
2 changes: 1 addition & 1 deletion cmd/item/item.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func ItemCommand() (string, error) {

flag.Parse()

if err := utils.ValidateItemArgs(os.Args); err != nil {
if err := utils.ValidateArgs(os.Args, utils.Validator{MaxArgs: 3, CmdName: "item", RequireName: true, HasFlags: false}); err != nil {
output.WriteString(err.Error())
return output.String(), err
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/move/move.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func MoveCommand() (string, error) {

flag.Parse()

if err := utils.ValidateMoveArgs(os.Args); err != nil {
if err := utils.ValidateArgs(os.Args, utils.Validator{MaxArgs: 3, CmdName: "move", RequireName: true, HasFlags: false}); err != nil {
output.WriteString(err.Error())
return output.String(), err
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/natures/natures.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func NaturesCommand() (string, error) {

flag.Parse()

if err := utils.ValidateNaturesArgs(os.Args); err != nil {
if err := utils.ValidateArgs(os.Args, utils.Validator{MaxArgs: 3, CmdName: "natures", RequireName: false, HasFlags: false}); err != nil {
output.WriteString(err.Error())
return output.String(), err
}
Expand Down
4 changes: 1 addition & 3 deletions cmd/pokemon/pokemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,9 @@ func PokemonCommand() (string, error) {
return output.String(), nil
}

flag.Parse()

err := utils.ValidatePokemonArgs(args)
if err != nil {
output.WriteString(err.Error()) // This is the styled error
output.WriteString(err.Error())
return output.String(), err
}

Expand Down
2 changes: 1 addition & 1 deletion cmd/search/search.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func SearchCommand() error {

flag.Parse()

if err := utils.ValidateSearchArgs(os.Args); err != nil {
if err := utils.ValidateArgs(os.Args, utils.Validator{MaxArgs: 3, CmdName: "search", RequireName: false, HasFlags: false}); err != nil {
fmt.Println(err.Error())
return err
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/speed/speed.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ func SpeedCommand() (string, error) {
flag.Parse()

// Validate arguments
if err := utils.ValidateSpeedArgs(os.Args); err != nil {
if err := utils.ValidateArgs(os.Args, utils.Validator{MaxArgs: 3, CmdName: "speed", RequireName: false, HasFlags: false}); err != nil {
output.WriteString(err.Error())
return output.String(), err
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func TypesCommand() (string, error) {
flag.Parse()

// Validate arguments
if err := utils.ValidateTypesArgs(os.Args); err != nil {
if err := utils.ValidateArgs(os.Args, utils.Validator{MaxArgs: 3, CmdName: "types", RequireName: false, HasFlags: false}); err != nil {
output.WriteString(err.Error())
return output.String(), err
}
Expand Down
Loading