Skip to content

Commit 9bd620f

Browse files
Merge pull request #239 from digitalghost-dev/1.8.8
1.8.8
2 parents 91a0621 + ba386d3 commit 9bd620f

27 files changed

Lines changed: 924 additions & 540 deletions

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ on:
3131
- main
3232

3333
env:
34-
VERSION_NUMBER: 'v1.8.7'
34+
VERSION_NUMBER: 'v1.8.8'
3535
DOCKERHUB_REGISTRY_NAME: 'digitalghostdev/poke-cli'
3636
AWS_REGION: 'us-west-2'
3737

.goreleaser.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ builds:
1414
- windows
1515
- darwin
1616
ldflags:
17-
- -s -w -X main.version=v1.8.7
17+
- -s -w -X main.version=v1.8.8
1818

1919
archives:
2020
- formats: [ 'zip' ]

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# build 1
2-
FROM golang:1.24.11-alpine3.23 AS build
2+
FROM golang:1.24.12-alpine3.23 AS build
33

44
WORKDIR /app
55

@@ -8,7 +8,7 @@ RUN go mod download
88

99
COPY . .
1010

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

1313
# build 2
1414
FROM --platform=$BUILDPLATFORM alpine:3.23

README.md

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<img width="425" src="poke-cli.png" alt="pokemon-logo"/>
33
<h4></h4>
44
<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">
5-
<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">
5+
<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">
66
<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">
77
</div>
88
<div align="center">
@@ -96,11 +96,11 @@ Cloudsmith is a fully cloud-based service that lets you easily create, store, an
9696
3. Choose how to interact with the container:
9797
* Run a single command and exit:
9898
```bash
99-
docker run --rm -it digitalghostdev/poke-cli:v1.8.7 <command> [subcommand] [flag]
99+
docker run --rm -it digitalghostdev/poke-cli:v1.8.8 <command> [subcommand] [flag]
100100
```
101101
* Enter the container and use its shell:
102102
```bash
103-
docker run --rm -it --name poke-cli --entrypoint /bin/sh digitalghostdev/poke-cli:v1.8.7 -c "cd /app && exec sh"
103+
docker run --rm -it --name poke-cli --entrypoint /bin/sh digitalghostdev/poke-cli:v1.8.8 -c "cd /app && exec sh"
104104
# placed into the /app directory, run the program with './poke-cli'
105105
# example: ./poke-cli ability swift-swim
106106
```
@@ -217,16 +217,17 @@ Below is a list of the planned/completed commands and flags:
217217

218218
---
219219
## Tested Terminals
220-
| Terminal | OS | Status | Issues |
221-
|-------------------|:-------------------------:|:------:|----------------------------------------------------------------------------------------------|
222-
| Alacritty | macOS, Ubuntu,<br>Windows | 🟡 | - Does not support sixel for TCG images. |
223-
| Ghostty | macOS | 🟡 | - Does not support sixel for TCG images. |
224-
| HyperJS | macOS | 🟡 | - Does not support sixel for TCG images. |
225-
| iTerm2 | macOS | 🟢 | - None |
226-
| Built-in Terminal | Ubuntu, Debian,<br>Fedora | 🟡 | - Does not support sixel for TCG images. |
227-
| Built-in Terminal | Alpine | 🟡 | - Some colors aren't supported.<br>- `pokemon <name> --image=xx` flag pixel issues. |
228-
| Built-in Terminal | macOS | 🟠 | - Does not support sixel for TCG images.<br>- `pokemon <name> --image=xx` flag pixel issues. |
229-
| Foot | Ubuntu | 🟢 | - None |
230-
| Tabby | Ubuntu | 🟢 | - None |
231-
| WezTerm | macOS, Windows | 🟡 | - Windows version has issues with displaying TCG images. |
232-
| Built-in Terminal | Windows | 🟢 | - None |
220+
| Terminal | OS | Status | Issues |
221+
|--------------------|-------------------------------|:------:|-----------------------------------------------------------------------------------|
222+
| Alacritty | macOS, Ubuntu, Windows | 🟡 | No support for TCG images |
223+
| Foot | Ubuntu, Fedora | 🟢 | None |
224+
| Ghostty | macOS | 🟢 | None |
225+
| iTerm2 | macOS | 🟢 | None |
226+
| Kitty | macOS, Ubuntu, Debian, Fedora | 🟢 | None |
227+
| Rio | macOS | 🟢 | None |
228+
| Tabby | Ubuntu | 🟢 | None |
229+
| Terminal (Alpine) | Alpine | 🟡 | Some colors aren't supported<br>`pokemon <name> --image=xx` flag has pixel issues |
230+
| Terminal (Linux) | Ubuntu, Debian, Fedora | 🟡 | No support for TCG images |
231+
| Terminal (macOS) | macOS | 🟠 | No support for TCG images<br>`pokemon <name> --image=xx` flag has pixel issues |
232+
| Terminal (Windows) | Windows | 🟢 | None |
233+
| WezTerm | macOS, Windows | 🟡 | Windows version has issues with displaying TCG images |

card_data/pipelines/poke_cli_dbt/dbt_project.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: 'poke_cli_dbt'
2-
version: '1.8.7'
2+
version: '1.8.8'
33

44
profile: 'poke_cli_dbt'
55

cmd/berry/berry.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ func (m model) View() string {
104104
Width(50).
105105
Height(29).
106106
Border(lipgloss.RoundedBorder()).
107-
BorderForeground(lipgloss.Color("#FFCC00")).
107+
BorderForeground(styling.YellowColor).
108108
Padding(1).
109109
Render(selectedBerry)
110110

@@ -142,11 +142,11 @@ func tableGeneration() error {
142142
s := table.DefaultStyles()
143143
s.Header = s.Header.
144144
BorderStyle(lipgloss.NormalBorder()).
145-
BorderForeground(lipgloss.Color("#FFCC00")).
145+
BorderForeground(styling.YellowColor).
146146
BorderBottom(true)
147147
s.Selected = s.Selected.
148148
Foreground(lipgloss.Color("#000")).
149-
Background(lipgloss.Color("#FFCC00"))
149+
Background(styling.YellowColor)
150150
t.SetStyles(s)
151151

152152
m := model{table: t}

cmd/berry/berry_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
tea "github.com/charmbracelet/bubbletea"
1111
"github.com/charmbracelet/lipgloss"
1212
"github.com/charmbracelet/x/exp/teatest"
13+
"github.com/digitalghost-dev/poke-cli/styling"
1314
"github.com/stretchr/testify/assert"
1415
"github.com/stretchr/testify/require"
1516
)
@@ -186,11 +187,11 @@ func createTestModel() model {
186187
s := table.DefaultStyles()
187188
s.Header = s.Header.
188189
BorderStyle(lipgloss.NormalBorder()).
189-
BorderForeground(lipgloss.Color("#FFCC00")).
190+
BorderForeground(styling.YellowColor).
190191
BorderBottom(true)
191192
s.Selected = s.Selected.
192193
Foreground(lipgloss.Color("#000")).
193-
Background(lipgloss.Color("#FFCC00"))
194+
Background(styling.YellowColor)
194195
t.SetStyles(s)
195196

196197
return model{table: t}

cmd/card/card.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ func CardCommand() (string, error) {
4040

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

61-
finalSetsModel, err := tea.NewProgram(setsModel).Run()
61+
finalSetsModel, err := tea.NewProgram(setsModel, tea.WithAltScreen()).Run()
6262
if err != nil {
6363
return "", fmt.Errorf("error running sets selection program: %w", err)
6464
}

cmd/card/cardinfo.go

Lines changed: 81 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,12 @@ import (
88
"io"
99
"net/http"
1010
"net/url"
11+
"os"
12+
"strings"
1113
"time"
1214

1315
"github.com/charmbracelet/x/ansi/sixel"
16+
"github.com/dolmen-go/kittyimg"
1417
"golang.org/x/image/draw"
1518
)
1619

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

23-
func CardImage(imageURL string) (string, error) {
26+
// supportsKittyGraphics checks if the terminal supports the Kitty graphics protocol
27+
func supportsKittyGraphics() bool {
28+
// Check Kitty-specific window ID
29+
if os.Getenv("KITTY_WINDOW_ID") != "" {
30+
return true
31+
}
32+
33+
// Check TERM_PROGRAM for known Kitty-compatible terminals
34+
termProgram := strings.ToLower(os.Getenv("TERM_PROGRAM"))
35+
switch termProgram {
36+
case "kitty", "ghostty", "wezterm":
37+
return true
38+
}
39+
40+
// Check TERM variable for kitty or ghostty
41+
term := strings.ToLower(os.Getenv("TERM"))
42+
switch {
43+
case strings.Contains(term, "kitty"):
44+
return true
45+
case strings.Contains(term, "ghostty"):
46+
return true
47+
}
48+
49+
return false
50+
}
51+
52+
// supportsSixelGraphics checks if the terminal supports the Sixel graphics protocol
53+
func supportsSixelGraphics() bool {
54+
session := os.Getenv("WT_SESSION")
55+
termProgram := strings.ToLower(os.Getenv("TERM_PROGRAM"))
56+
term := strings.ToLower(os.Getenv("TERM"))
57+
58+
if session != "" {
59+
return true
60+
}
61+
62+
// Check TERM_PROGRAM for known Sixel-supporting terminals
63+
switch termProgram {
64+
case "iterm.app", "wezterm", "konsole", "tabby", "rio":
65+
return true
66+
}
67+
68+
// Check TERM variable for known Sixel-supporting terminals
69+
switch {
70+
case term == "foot" || strings.HasPrefix(term, "foot-"):
71+
return true
72+
case term == "xterm-sixel" || strings.Contains(term, "sixel"):
73+
return true
74+
}
75+
76+
return false
77+
}
78+
79+
// CardImage downloads and renders an image using Kitty protocol if supported, otherwise Sixel.
80+
func CardImage(imageURL string) (imageData string, protocol string, err error) {
2481
client := &http.Client{
2582
Timeout: time.Second * 60,
2683
}
2784
parsedURL, err := url.Parse(imageURL)
2885
if err != nil || (parsedURL.Scheme != "http" && parsedURL.Scheme != "https") {
29-
return "", errors.New("invalid URL scheme")
86+
return "", "", errors.New("invalid URL scheme")
3087
}
3188
resp, err := client.Get(imageURL)
3289
if err != nil {
33-
return "", fmt.Errorf("failed to fetch image: %w", err)
90+
return "", "", fmt.Errorf("failed to fetch image: %w", err)
3491
}
3592
defer resp.Body.Close()
3693

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

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

48105
img, _, err := image.Decode(bytes.NewReader(bodyBytes))
49106
if err != nil {
50-
return "", fmt.Errorf("failed to decode image: %w", err)
107+
return "", "", fmt.Errorf("failed to decode image: %w", err)
51108
}
52109

53110
resized := resizeImage(img, 500, 675)
54111

55-
// Build Sixel string to return
56112
var buf bytes.Buffer
57-
buf.WriteString("\x1bPq")
58-
if err := new(sixel.Encoder).Encode(&buf, resized); err != nil {
59-
return "", fmt.Errorf("failed to encode sixel: %w", err)
113+
114+
if supportsKittyGraphics() {
115+
if err := kittyimg.Fprint(&buf, resized); err != nil {
116+
return "", "", fmt.Errorf("failed to encode kitty image: %w", err)
117+
}
118+
return buf.String(), "Kitty", nil
119+
}
120+
121+
// Fall back to Sixel
122+
if supportsSixelGraphics() {
123+
buf.WriteString("\x1bPq")
124+
if err := new(sixel.Encoder).Encode(&buf, resized); err != nil {
125+
return "", "", fmt.Errorf("failed to encode sixel: %w", err)
126+
}
127+
buf.WriteString("\x1b\\")
128+
return buf.String(), "Sixel", nil
60129
}
61-
buf.WriteString("\x1b\\")
62130

63-
return buf.String(), nil
131+
// Neither protocol is supported
132+
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")
64133
}

0 commit comments

Comments
 (0)