Skip to content
Merged

1.8.8 #239

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.7'
VERSION_NUMBER: 'v1.8.8'
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.7
- -s -w -X main.version=v1.8.8

archives:
- formats: [ 'zip' ]
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# build 1
FROM golang:1.24.11-alpine3.23 AS build
FROM golang:1.24.12-alpine3.23 AS build

WORKDIR /app

Expand All @@ -8,7 +8,7 @@ RUN go mod download

COPY . .

RUN go build -ldflags "-X main.version=v1.8.7" -o poke-cli .
RUN go build -ldflags "-X main.version=v1.8.8" -o poke-cli .

# build 2
FROM --platform=$BUILDPLATFORM alpine:3.23
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 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.7?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.8?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 @@ -96,11 +96,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.7 <command> [subcommand] [flag]
docker run --rm -it digitalghostdev/poke-cli:v1.8.8 <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.7 -c "cd /app && exec sh"
docker run --rm -it --name poke-cli --entrypoint /bin/sh digitalghostdev/poke-cli:v1.8.8 -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 @@ -217,16 +217,17 @@ Below is a list of the planned/completed commands and flags:

---
## Tested Terminals
| Terminal | OS | Status | Issues |
|-------------------|:-------------------------:|:------:|----------------------------------------------------------------------------------------------|
| Alacritty | macOS, Ubuntu,<br>Windows | 🟡 | - Does not support sixel for TCG images. |
| Ghostty | macOS | 🟡 | - Does not support sixel for TCG images. |
| HyperJS | macOS | 🟡 | - Does not support sixel for TCG images. |
| iTerm2 | macOS | 🟢 | - None |
| Built-in Terminal | Ubuntu, Debian,<br>Fedora | 🟡 | - Does not support sixel for TCG images. |
| Built-in Terminal | Alpine | 🟡 | - Some colors aren't supported.<br>- `pokemon <name> --image=xx` flag pixel issues. |
| Built-in Terminal | macOS | 🟠 | - Does not support sixel for TCG images.<br>- `pokemon <name> --image=xx` flag pixel issues. |
| Foot | Ubuntu | 🟢 | - None |
| Tabby | Ubuntu | 🟢 | - None |
| WezTerm | macOS, Windows | 🟡 | - Windows version has issues with displaying TCG images. |
| Built-in Terminal | Windows | 🟢 | - None |
| Terminal | OS | Status | Issues |
|--------------------|-------------------------------|:------:|-----------------------------------------------------------------------------------|
| Alacritty | macOS, Ubuntu, Windows | 🟡 | No support for TCG images |
| Foot | Ubuntu, Fedora | 🟢 | None |
| Ghostty | macOS | 🟢 | None |
| iTerm2 | macOS | 🟢 | None |
| Kitty | macOS, Ubuntu, Debian, Fedora | 🟢 | None |
| Rio | macOS | 🟢 | None |
| Tabby | Ubuntu | 🟢 | None |
| Terminal (Alpine) | Alpine | 🟡 | Some colors aren't supported<br>`pokemon <name> --image=xx` flag has pixel issues |
| Terminal (Linux) | Ubuntu, Debian, Fedora | 🟡 | No support for TCG images |
| Terminal (macOS) | macOS | 🟠 | No support for TCG images<br>`pokemon <name> --image=xx` flag has pixel issues |
| Terminal (Windows) | Windows | 🟢 | None |
| WezTerm | macOS, Windows | 🟡 | Windows version has issues with displaying TCG images |
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.7'
version: '1.8.8'

profile: 'poke_cli_dbt'

Expand Down
6 changes: 3 additions & 3 deletions cmd/berry/berry.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ func (m model) View() string {
Width(50).
Height(29).
Border(lipgloss.RoundedBorder()).
BorderForeground(lipgloss.Color("#FFCC00")).
BorderForeground(styling.YellowColor).
Padding(1).
Render(selectedBerry)

Expand Down Expand Up @@ -142,11 +142,11 @@ func tableGeneration() error {
s := table.DefaultStyles()
s.Header = s.Header.
BorderStyle(lipgloss.NormalBorder()).
BorderForeground(lipgloss.Color("#FFCC00")).
BorderForeground(styling.YellowColor).
BorderBottom(true)
s.Selected = s.Selected.
Foreground(lipgloss.Color("#000")).
Background(lipgloss.Color("#FFCC00"))
Background(styling.YellowColor)
t.SetStyles(s)

m := model{table: t}
Expand Down
5 changes: 3 additions & 2 deletions cmd/berry/berry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
tea "github.com/charmbracelet/bubbletea"
"github.com/charmbracelet/lipgloss"
"github.com/charmbracelet/x/exp/teatest"
"github.com/digitalghost-dev/poke-cli/styling"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
Expand Down Expand Up @@ -186,11 +187,11 @@ func createTestModel() model {
s := table.DefaultStyles()
s.Header = s.Header.
BorderStyle(lipgloss.NormalBorder()).
BorderForeground(lipgloss.Color("#FFCC00")).
BorderForeground(styling.YellowColor).
BorderBottom(true)
s.Selected = s.Selected.
Foreground(lipgloss.Color("#000")).
Background(lipgloss.Color("#FFCC00"))
Background(styling.YellowColor)
t.SetStyles(s)

return model{table: t}
Expand Down
4 changes: 2 additions & 2 deletions cmd/card/card.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func CardCommand() (string, error) {

seriesModel := SeriesList()
// Program 1: Series selection
finalModel, err := tea.NewProgram(seriesModel).Run()
finalModel, err := tea.NewProgram(seriesModel, tea.WithAltScreen()).Run()
if err != nil {
return "", fmt.Errorf("error running series selection program: %w", err)
}
Expand All @@ -58,7 +58,7 @@ func CardCommand() (string, error) {
return "", fmt.Errorf("error loading sets: %w", err)
}

finalSetsModel, err := tea.NewProgram(setsModel).Run()
finalSetsModel, err := tea.NewProgram(setsModel, tea.WithAltScreen()).Run()
if err != nil {
return "", fmt.Errorf("error running sets selection program: %w", err)
}
Expand Down
93 changes: 81 additions & 12 deletions cmd/card/cardinfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,12 @@ import (
"io"
"net/http"
"net/url"
"os"
"strings"
"time"

"github.com/charmbracelet/x/ansi/sixel"
"github.com/dolmen-go/kittyimg"
"golang.org/x/image/draw"
)

Expand All @@ -20,45 +23,111 @@ func resizeImage(img image.Image, width, height int) image.Image {
return dst
}

func CardImage(imageURL string) (string, error) {
// supportsKittyGraphics checks if the terminal supports the Kitty graphics protocol
func supportsKittyGraphics() bool {
// Check Kitty-specific window ID
if os.Getenv("KITTY_WINDOW_ID") != "" {
return true
}

// Check TERM_PROGRAM for known Kitty-compatible terminals
termProgram := strings.ToLower(os.Getenv("TERM_PROGRAM"))
switch termProgram {
case "kitty", "ghostty", "wezterm":
return true
}

// Check TERM variable for kitty or ghostty
term := strings.ToLower(os.Getenv("TERM"))
switch {
case strings.Contains(term, "kitty"):
return true
case strings.Contains(term, "ghostty"):
return true
}

return false
}

// supportsSixelGraphics checks if the terminal supports the Sixel graphics protocol
func supportsSixelGraphics() bool {
session := os.Getenv("WT_SESSION")
termProgram := strings.ToLower(os.Getenv("TERM_PROGRAM"))
term := strings.ToLower(os.Getenv("TERM"))

if session != "" {
return true
}

// Check TERM_PROGRAM for known Sixel-supporting terminals
switch termProgram {
case "iterm.app", "wezterm", "konsole", "tabby", "rio":
return true
}

// Check TERM variable for known Sixel-supporting terminals
switch {
case term == "foot" || strings.HasPrefix(term, "foot-"):
return true
case term == "xterm-sixel" || strings.Contains(term, "sixel"):
return true
}

return false
}

// CardImage downloads and renders an image using Kitty protocol if supported, otherwise Sixel.
func CardImage(imageURL string) (imageData string, protocol string, err error) {
client := &http.Client{
Timeout: time.Second * 60,
}
parsedURL, err := url.Parse(imageURL)
if err != nil || (parsedURL.Scheme != "http" && parsedURL.Scheme != "https") {
return "", errors.New("invalid URL scheme")
return "", "", errors.New("invalid URL scheme")
}
resp, err := client.Get(imageURL)
if err != nil {
return "", fmt.Errorf("failed to fetch image: %w", err)
return "", "", fmt.Errorf("failed to fetch image: %w", err)
}
defer resp.Body.Close()

if resp.StatusCode != http.StatusOK {
return "", fmt.Errorf("non-200 response: %d", resp.StatusCode)
return "", "", fmt.Errorf("non-200 response: %d", resp.StatusCode)
}

// Read body into memory first to avoid timeout during decode
limitedBody := io.LimitReader(resp.Body, 10*1024*1024)
bodyBytes, err := io.ReadAll(limitedBody)
if err != nil {
return "", fmt.Errorf("failed to read image data: %w", err)
return "", "", fmt.Errorf("failed to read image data: %w", err)
}

img, _, err := image.Decode(bytes.NewReader(bodyBytes))
if err != nil {
return "", fmt.Errorf("failed to decode image: %w", err)
return "", "", fmt.Errorf("failed to decode image: %w", err)
}

resized := resizeImage(img, 500, 675)

// Build Sixel string to return
var buf bytes.Buffer
buf.WriteString("\x1bPq")
if err := new(sixel.Encoder).Encode(&buf, resized); err != nil {
return "", fmt.Errorf("failed to encode sixel: %w", err)

if supportsKittyGraphics() {
if err := kittyimg.Fprint(&buf, resized); err != nil {
return "", "", fmt.Errorf("failed to encode kitty image: %w", err)
}
return buf.String(), "Kitty", nil
}

// Fall back to Sixel
if supportsSixelGraphics() {
buf.WriteString("\x1bPq")
if err := new(sixel.Encoder).Encode(&buf, resized); err != nil {
return "", "", fmt.Errorf("failed to encode sixel: %w", err)
}
buf.WriteString("\x1b\\")
return buf.String(), "Sixel", nil
}
buf.WriteString("\x1b\\")

return buf.String(), nil
// Neither protocol is supported
return "", "", errors.New("your terminal does not support image rendering (Kitty or Sixel graphics protocols required)\n\nTry using: Kitty, Ghostty, WezTerm, iTerm2, or foot")
}
Loading