Skip to content

Commit 7556770

Browse files
Merge pull request #107 from digitalghost-dev/0.12.2
0.12.2
2 parents ed6e50d + 4d1a2a6 commit 7556770

27 files changed

+355
-314
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ on:
2626
- main
2727

2828
env:
29-
VERSION_NUMBER: 'v0.12.1'
29+
VERSION_NUMBER: 'v0.12.2'
3030
DOCKERHUB_REGISTRY_NAME: 'digitalghostdev/poke-cli'
3131
AWS_REGION: 'us-west-2'
3232

.goreleaser.yaml

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=v0.12.1
17+
- -s -w -X main.version=v0.12.2
1818

1919
archives:
2020
- format: tar.gz

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ RUN go mod download
88

99
COPY . .
1010

11-
RUN go build -ldflags "-X main.version=v0.12.1" -o poke-cli .
11+
RUN go build -ldflags "-X main.version=v0.12.2" -o poke-cli .
1212

1313
# build 2
1414
FROM gcr.io/distroless/static-debian12:nonroot

README.md

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<img height="250" width="350" src="pokemon.svg" alt="pokemon-logo"/>
33
<h1>Pokémon CLI</h1>
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/v0.12.1?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/v0.12.2?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">
@@ -12,10 +12,10 @@
1212
</div>
1313

1414
## Overview
15-
A CLI tool for viewing data about Pokémon from your terminal! I am new to writing Go and taking my time in building this
15+
`poke-cli` is a hybrid of a classic CLI and modern TUI tool for viewing data about Pokémon! I am new to writing Go and taking my time in building this
1616
project.
1717

18-
My aim is to have five commands finished for `v1.0.0`. Read more in the [Roadmap](#roadmap) section.
18+
My aim is to have eight commands finished for `v1.0.0`. Read more in the [Roadmap](#roadmap) section.
1919

2020
---
2121
## Demo
@@ -68,7 +68,7 @@ _Use a Docker Image_
6868
* Necessary.
6969

7070
```bash
71-
docker run --rm -i -t digitalghostdev/poke-cli:v0.12.1 <command> [subcommand] flag]
71+
docker run --rm -i -t digitalghostdev/poke-cli:v0.12.2 <command> [subcommand] flag]
7272
```
7373

7474
### Go Install
@@ -115,15 +115,20 @@ The architecture behind how the tool works is straight forward.
115115

116116
_Not 100% up-to-date, may add or remove some of these choices_
117117

118+
Below are the commands and flags that are planned for `v1.0.0`
119+
118120
- [x] `ability`: get data about a specific ability.
119121
- [x] `-p | --pokemon`: display Pokémon that learn this ability.
122+
- [ ] `berry`: get data about a specific berry.
120123
- [ ] `move`: get data about a specific move.
121124
- [ ] `-p | --pokemon`: display Pokémon that learn this move.
122125
- [x] `natures`: get data about natures.
123126
- [ ] `pokemon`: get data about a specific Pokémon.
124-
- [x] `-a | --abilities`: display the Pokémon's abilities.
125-
- [x] `-i | --image`: display a pixel image of the Pokémon.
126-
- [x] `-s | --stats`: display the Pokémon's base stats.
127-
- [x] `-t | --types`: display the Pokémon's typing.
128-
- [ ] `-m | --moves`: display learnable moves.
127+
- [x] `-a | --abilities`: display the Pokémon's abilities.
128+
- [x] `-i | --image`: display a pixel image of the Pokémon.
129+
- [x] `-s | --stats`: display the Pokémon's base stats.
130+
- [x] `-t | --types`: display the Pokémon's typing.
131+
- [ ] `-m | --moves`: display learnable moves.
132+
- [ ] `search`: search for a resource (`ability`, `berry`, `pokemon`, `move`)
133+
- [ ] `speed`: compare speed stats between two Pokémon.
129134
- [x] `types`: get data about a specific typing.

cli.go

Lines changed: 15 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,13 @@ package main
33
import (
44
"flag"
55
"fmt"
6-
"github.com/charmbracelet/lipgloss"
76
"github.com/digitalghost-dev/poke-cli/cmd"
87
"github.com/digitalghost-dev/poke-cli/flags"
8+
"github.com/digitalghost-dev/poke-cli/styling"
99
"os"
1010
"runtime/debug"
1111
)
1212

13-
var (
14-
styleBold = lipgloss.NewStyle().Bold(true)
15-
helpBorder = lipgloss.NewStyle().
16-
BorderStyle(lipgloss.RoundedBorder()).
17-
BorderForeground(lipgloss.Color("#FFCC00"))
18-
errorColor = lipgloss.NewStyle().Foreground(lipgloss.Color("#F2055C"))
19-
errorBorder = lipgloss.NewStyle().
20-
BorderStyle(lipgloss.RoundedBorder()).
21-
BorderForeground(lipgloss.Color("#F2055C"))
22-
)
23-
2413
var version = "(devel)"
2514

2615
func currentVersion() {
@@ -56,21 +45,21 @@ func runCLI(args []string) int {
5645
shortCurrentVersionFlag := mainFlagSet.Bool("v", false, "Prints the current version")
5746

5847
mainFlagSet.Usage = func() {
59-
helpMessage := helpBorder.Render(
48+
helpMessage := styling.HelpBorder.Render(
6049
"Welcome! This tool displays data related to Pokémon!",
61-
"\n\n", styleBold.Render("USAGE:"),
50+
"\n\n", styling.StyleBold.Render("USAGE:"),
6251
fmt.Sprintf("\n\t%-15s %s", "poke-cli [flag]", ""),
6352
fmt.Sprintf("\n\t%-15s %s", "poke-cli <command> [flag]", ""),
6453
fmt.Sprintf("\n\t%-15s %s", "poke-cli <command> <subcommand> [flag]", ""),
65-
"\n\n", styleBold.Render("FLAGS:"),
54+
"\n\n", styling.StyleBold.Render("FLAGS:"),
6655
fmt.Sprintf("\n\t%-15s %s", "-h, --help", "Shows the help menu"),
6756
fmt.Sprintf("\n\t%-15s %s", "-l, --latest", "Prints the latest version available"),
6857
fmt.Sprintf("\n\t%-15s %s", "-v, --version", "Prints the current version"),
69-
"\n\n", styleBold.Render("COMMANDS:"),
58+
"\n\n", styling.StyleBold.Render("COMMANDS:"),
7059
fmt.Sprintf("\n\t%-15s %s", "ability", "Get details about an ability"),
71-
fmt.Sprintf("\n\t%-15s %s", "natures", "Get details about Pokémon natures"),
72-
fmt.Sprintf("\n\t%-15s %s", "pokemon", "Get details about a specific Pokémon"),
73-
fmt.Sprintf("\n\t%-15s %s", "types", "Get details about a specific typing"),
60+
fmt.Sprintf("\n\t%-15s %s", "natures", "Get details about all natures"),
61+
fmt.Sprintf("\n\t%-15s %s", "pokemon", "Get details about a Pokémon"),
62+
fmt.Sprintf("\n\t%-15s %s", "types", "Get details about a typing"),
7463
)
7564
fmt.Println(helpMessage)
7665
}
@@ -112,15 +101,15 @@ func runCLI(args []string) int {
112101
return 0
113102
} else {
114103
command := os.Args[1]
115-
errMessage := errorBorder.Render(
116-
errorColor.Render("Error!"),
104+
errMessage := styling.ErrorBorder.Render(
105+
styling.ErrorColor.Render("Error!"),
117106
fmt.Sprintf("\n\t%-15s", fmt.Sprintf("'%s' is not a valid command.\n", command)),
118-
styleBold.Render("\nCommands:"),
107+
styling.StyleBold.Render("\nCommands:"),
119108
fmt.Sprintf("\n\t%-15s %s", "ability", "Get details about an ability"),
120-
fmt.Sprintf("\n\t%-15s %s", "natures", "Get details about Pokémon natures"),
121-
fmt.Sprintf("\n\t%-15s %s", "pokemon", "Get details about a specific Pokémon"),
122-
fmt.Sprintf("\n\t%-15s %s", "types", "Get details about a specific typing"),
123-
fmt.Sprintf("\n\nAlso run %s for more info!", styleBold.Render("poke-cli -h")),
109+
fmt.Sprintf("\n\t%-15s %s", "natures", "Get details about all natures"),
110+
fmt.Sprintf("\n\t%-15s %s", "pokemon", "Get details about a Pokémon"),
111+
fmt.Sprintf("\n\t%-15s %s", "types", "Get details about a typing"),
112+
fmt.Sprintf("\n\nAlso run %s for more info!", styling.StyleBold.Render("poke-cli -h")),
124113
)
125114
fmt.Printf("%s\n", errMessage)
126115
return 1

cli_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ func TestRunCLI(t *testing.T) {
173173
{
174174
name: "Latest Flag",
175175
args: []string{"-l"},
176-
expectedOutput: "Latest Docker image version: v0.12.0\nLatest release tag: v0.12.0\n",
176+
expectedOutput: "Latest Docker image version: v0.12.1\nLatest release tag: v0.12.1\n",
177177
expectedCode: 0,
178178
},
179179
}

cmd/ability.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"fmt"
66
"github.com/digitalghost-dev/poke-cli/connections"
77
"github.com/digitalghost-dev/poke-cli/flags"
8+
"github.com/digitalghost-dev/poke-cli/styling"
89
"golang.org/x/text/cases"
910
"golang.org/x/text/language"
1011
"os"
@@ -14,13 +15,13 @@ import (
1415
func AbilityCommand() {
1516

1617
flag.Usage = func() {
17-
helpMessage := helpBorder.Render(
18+
helpMessage := styling.HelpBorder.Render(
1819
"Get details about a specific ability.\n\n",
19-
styleBold.Render("USAGE:"),
20-
fmt.Sprintf("\n\t%s %s %s %s", "poke-cli", styleBold.Render("ability"), "<ability-name>", "[flag]"),
21-
fmt.Sprintf("\n\t%-30s", styleItalic.Render("Use a hyphen when typing a name with a space.")),
20+
styling.StyleBold.Render("USAGE:"),
21+
fmt.Sprintf("\n\t%s %s %s %s", "poke-cli", styling.StyleBold.Render("ability"), "<ability-name>", "[flag]"),
22+
fmt.Sprintf("\n\t%-30s", styling.StyleItalic.Render("Use a hyphen when typing a name with a space.")),
2223
"\n\n",
23-
styleBold.Render("FLAGS:"),
24+
styling.StyleBold.Render("FLAGS:"),
2425
fmt.Sprintf("\n\t%-30s %s", "-p, --pokemon", "Prints Pokémon that learn this ability."),
2526
fmt.Sprintf("\n\t%-30s %s", "-h, --help", "Prints the help menu."),
2627
)
@@ -69,7 +70,7 @@ func AbilityCommand() {
6970
}
7071

7172
capitalizedEffect := cases.Title(language.English).String(strings.Replace(abilityName, "-", " ", -1))
72-
fmt.Println(styleBold.Render(capitalizedEffect))
73+
fmt.Println(styling.StyleBold.Render(capitalizedEffect))
7374
fmt.Println("Effect:", englishShortEffect)
7475

7576
if *pokemonFlag || *shortPokemonFlag {

cmd/ability_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package cmd
33
import (
44
"bytes"
55
"fmt"
6+
"github.com/digitalghost-dev/poke-cli/styling"
67
"log"
78
"os"
89
"strings"
@@ -61,7 +62,7 @@ func TestAbilityCommand(t *testing.T) {
6162
{
6263
name: "Valid Execution",
6364
args: []string{"ability", "stench"},
64-
expectedOutput: stripANSI("Stench\nEffect: Has a 10% chance of making target Pokémon flinch with each hit."),
65+
expectedOutput: styling.StripANSI("Stench\nEffect: Has a 10% chance of making target Pokémon flinch with each hit."),
6566
expectError: false,
6667
},
6768
}

cmd/natures.go

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,17 @@ import (
55
"fmt"
66
"github.com/charmbracelet/lipgloss"
77
"github.com/charmbracelet/lipgloss/table"
8+
"github.com/digitalghost-dev/poke-cli/styling"
89
"os"
910
)
1011

1112
func NaturesCommand() {
1213

1314
flag.Usage = func() {
14-
helpMessage := helpBorder.Render(
15-
"Get details about Pokémon natures.\n\n",
16-
styleBold.Render("USAGE:"),
17-
fmt.Sprintf("\n\t%s %s %s", "poke-cli", styleBold.Render("natures"), "[flag]"),
18-
"\n\n",
19-
styleBold.Render("FLAGS:"),
20-
fmt.Sprintf("\n\t%-30s %s", "-h, --help", "Prints out the help menu."),
15+
helpMessage := styling.HelpBorder.Render(
16+
"Get details about all natures.\n\n",
17+
styling.StyleBold.Render("USAGE:"),
18+
fmt.Sprintf("\n\t%s %s", "poke-cli", styling.StyleBold.Render("natures")),
2119
)
2220
fmt.Println(helpMessage)
2321
}
@@ -32,20 +30,20 @@ func NaturesCommand() {
3230
fmt.Println("Natures affect the growth of a Pokémon.\n" +
3331
"Each nature increases one of its stats by 10% and decreases one by 10%.\n" +
3432
"Five natures increase and decrease the same stat and therefore have no effect.\n\n" +
35-
styleBold.Render("Nature Chart:"))
33+
styling.StyleBold.Render("Nature Chart:"))
3634

3735
chart := [][]string{
38-
{" ", red.Render("-Attack"), red.Render("-Defense"), red.Render("-Sp. Atk"), red.Render("-Sp. Def"), red.Render("Speed")},
39-
{green.Render("+Attack"), "Hardy", "Lonely", "Adamant", "Naughty", "Brave"},
40-
{green.Render("+Defense"), "Bold", "Docile", "Impish", "Lax", "Relaxed"},
41-
{green.Render("+Sp. Atk"), "Modest", "Mild", "Bashful", "Rash", "Quiet"},
42-
{green.Render("+Sp. Def"), "Calm", "Gentle", "Careful", "Quirky", "Sassy"},
43-
{green.Render("Speed"), "Timid", "Hasty", "Jolly", "Naive", "Serious"},
36+
{" ", styling.Red.Render("-Attack"), styling.Red.Render("-Defense"), styling.Red.Render("-Sp. Atk"), styling.Red.Render("-Sp. Def"), styling.Red.Render("Speed")},
37+
{styling.Green.Render("+Attack"), "Hardy", "Lonely", "Adamant", "Naughty", "Brave"},
38+
{styling.Green.Render("+Defense"), "Bold", "Docile", "Impish", "Lax", "Relaxed"},
39+
{styling.Green.Render("+Sp. Atk"), "Modest", "Mild", "Bashful", "Rash", "Quiet"},
40+
{styling.Green.Render("+Sp. Def"), "Calm", "Gentle", "Careful", "Quirky", "Sassy"},
41+
{styling.Green.Render("Speed"), "Timid", "Hasty", "Jolly", "Naive", "Serious"},
4442
}
4543

4644
t := table.New().
4745
Border(lipgloss.NormalBorder()).
48-
BorderStyle(lipgloss.NewStyle().Foreground(gray)).
46+
BorderStyle(lipgloss.NewStyle().Foreground(styling.Gray)).
4947
BorderRow(true).
5048
BorderColumn(true).
5149
Rows(chart...).

cmd/pokemon.go

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"fmt"
66
"github.com/digitalghost-dev/poke-cli/connections"
77
"github.com/digitalghost-dev/poke-cli/flags"
8+
"github.com/digitalghost-dev/poke-cli/styling"
89
"golang.org/x/text/cases"
910
"golang.org/x/text/language"
1011
"math"
@@ -15,16 +16,16 @@ import (
1516
// PokemonCommand processes the Pokémon command
1617
func PokemonCommand() {
1718

18-
hintMessage := styleItalic.Render("options: [sm, md, lg]")
19+
hintMessage := styling.StyleItalic.Render("options: [sm, md, lg]")
1920

2021
flag.Usage = func() {
21-
helpMessage := helpBorder.Render(
22+
helpMessage := styling.HelpBorder.Render(
2223
"Get details about a specific Pokémon.\n\n",
23-
styleBold.Render("USAGE:"),
24-
fmt.Sprintf("\n\t%s %s %s %s", "poke-cli", styleBold.Render("pokemon"), "<pokemon-name>", "[flag]"),
25-
fmt.Sprintf("\n\t%-30s", styleItalic.Render("Use a hyphen when typing a name with a space.")),
24+
styling.StyleBold.Render("USAGE:"),
25+
fmt.Sprintf("\n\t%s %s %s %s", "poke-cli", styling.StyleBold.Render("pokemon"), "<pokemon-name>", "[flag]"),
26+
fmt.Sprintf("\n\t%-30s", styling.StyleItalic.Render("Use a hyphen when typing a name with a space.")),
2627
"\n\n",
27-
styleBold.Render("FLAGS:"),
28+
styling.StyleBold.Render("FLAGS:"),
2829
fmt.Sprintf("\n\t%-30s %s", "-a, --abilities", "Prints the Pokémon's abilities."),
2930
fmt.Sprintf("\n\t%-30s %s", "-i=xx, --image=xx", "Prints out the Pokémon's default sprite."),
3031
fmt.Sprintf("\n\t%5s%-15s", "", hintMessage),
@@ -42,15 +43,15 @@ func PokemonCommand() {
4243
// Pre-parse validation for empty image flag values
4344
for _, arg := range args {
4445
if strings.HasPrefix(arg, "-i=") && len(arg) == 3 {
45-
fmt.Println(errorBorder.Render(errorColor.Render("Error!"), "\nThe image flag (-i or --image) requires a non-empty value.\nValid sizes are: lg, md, sm."))
46+
fmt.Println(styling.ErrorBorder.Render(styling.ErrorColor.Render("Error!"), "\nThe image flag (-i or --image) requires a non-empty value.\nValid sizes are: lg, md, sm."))
4647
os.Exit(1)
4748
}
4849
if strings.HasPrefix(arg, "--image=") && len(arg) == 8 {
49-
fmt.Println(errorBorder.Render(errorColor.Render("Error!"), "\nThe image flag (-i or --image) requires a non-empty value.\nValid sizes are: lg, md, sm."))
50+
fmt.Println(styling.ErrorBorder.Render(styling.ErrorColor.Render("Error!"), "\nThe image flag (-i or --image) requires a non-empty value.\nValid sizes are: lg, md, sm."))
5051
os.Exit(1)
5152
}
5253
if strings.HasPrefix(arg, "-image=") && len(arg) == 7 {
53-
fmt.Println(errorBorder.Render(errorColor.Render("Error!"), "\nThe image flag (-i or --image) requires a non-empty value.\nValid sizes are: lg, md, sm."))
54+
fmt.Println(styling.ErrorBorder.Render(styling.ErrorColor.Render("Error!"), "\nThe image flag (-i or --image) requires a non-empty value.\nValid sizes are: lg, md, sm."))
5455
os.Exit(1)
5556
}
5657
}

0 commit comments

Comments
 (0)