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 @@ -25,7 +25,7 @@ on:
- main

env:
VERSION_NUMBER: 'v0.9.3'
VERSION_NUMBER: 'v0.10.0'
DOCKERHUB_REGISTRY_NAME: 'digitalghostdev/poke-cli'
AWS_REGION: 'us-west-2'

Expand Down
2 changes: 1 addition & 1 deletion .goreleaser.yaml
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=v0.9.3
- -s -w -X main.version=v0.10.0

archives:
- format: tar.gz
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=v0.9.3" -o poke-cli .
RUN go build -ldflags "-X main.version=v0.10.0" -o poke-cli .

# build 2
FROM gcr.io/distroless/static-debian12:nonroot
Expand Down
54 changes: 29 additions & 25 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="https://cdn.simpleicons.org/pokemon/FFCC00" 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/v0.9.3?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/v0.10.0?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 @@ -15,11 +15,11 @@
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
project.

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

---
## Demo
![demo](https://poke-cli-s3-bucket.s3.us-west-2.amazonaws.com/demo-v0.9.3.gif)
![demo](https://poke-cli-s3-bucket.s3.us-west-2.amazonaws.com/demo-v0.10.0.gif)

---
## Install
Expand Down Expand Up @@ -68,7 +68,7 @@ _Use a Docker Image_
* Necessary.

```bash
docker run --rm -i -t digitalghostdev/poke-cli:v0.9.3 <command> [subcommand] flag]
docker run --rm -i -t digitalghostdev/poke-cli:v0.10.0 <command> [subcommand] flag]
```

### Go Install
Expand All @@ -83,23 +83,25 @@ _If you have Go already, install the executable yourself_
## Usage
By running `poke-cli [-h | --help]`, it'll display information on how to use the tool.
```
╭────────────────────────────────────────────────────────╮
│Welcome! This tool displays data related to Pokémon! │
│ │
│ USAGE: │
│ poke-cli [flag] │
│ poke-cli <command> [flag] │
│ poke-cli <command> <subcommand> [flag] │
│ │
│ FLAGS: │
│ -h, --help Shows the help menu │
│ -l, --latest Prints the latest version available │
│ -v, --version Prints the current version │
│ │
│ AVAILABLE COMMANDS: │
│ pokemon Get details of a specific Pokémon │
│ types Get details of a specific typing │
╰────────────────────────────────────────────────────────╯
╭─────────────────────────────────────────────────────────╮
│Welcome! This tool displays data related to Pokémon! │
│ │
│ USAGE: │
│ poke-cli [flag] │
│ poke-cli <command> [flag] │
│ poke-cli <command> <subcommand> [flag] │
│ │
│ FLAGS: │
│ -h, --help Shows the help menu │
│ -l, --latest Prints the latest version available │
│ -v, --version Prints the current version │
│ │
│ COMMANDS: │
│ natures Get details about Pokémon natures │
│ pokemon Get details about a specific Pokémon │
│ types Get details about a specific typing │
╰─────────────────────────────────────────────────────────╯

```

---
Expand All @@ -112,13 +114,15 @@ The architecture behind how the tool works is straight forward.

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

- [ ] `ability`: get data about a specific ability.
- [ ] `-p | --pokemon`: display Pokémon that learn this ability.
- [ ] `move`: get data about a specific move.
- [ ] `-p | --pokemon`: display Pokémon that learn this move.
- [x] `natures`: get data about natures.
- [ ] `pokemon`: get data about a specific Pokémon.
- [x] `-a | --abilities`: display the Pokémon's abilities.
- [ ] `-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.
- [ ] `-m | --moves`: display learnable moves.
- [x] `types`: get data about a specific typing.
- [ ] `ability`: get data about a specific ability.
- [ ] `-p | --pokemon`: display Pokémon that learn this ability.
- [ ] `move`: get data about a specific move.
- [ ] `-p | --pokemon`: display Pokémon that learn this move.
17 changes: 10 additions & 7 deletions cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,10 @@ func runCLI(args []string) int {
fmt.Sprintf("\n\t%-15s %s", "-h, --help", "Shows the help menu"),
fmt.Sprintf("\n\t%-15s %s", "-l, --latest", "Prints the latest version available"),
fmt.Sprintf("\n\t%-15s %s", "-v, --version", "Prints the current version"),
"\n\n", styleBold.Render("AVAILABLE COMMANDS:"),
fmt.Sprintf("\n\t%-15s %s", "pokemon", "Get details of a specific Pokémon"),
fmt.Sprintf("\n\t%-15s %s", "types", "Get details of a specific typing"),
"\n\n", styleBold.Render("COMMANDS:"),
fmt.Sprintf("\n\t%-15s %s", "natures", "Get details about Pokémon natures"),
fmt.Sprintf("\n\t%-15s %s", "pokemon", "Get details about a specific Pokémon"),
fmt.Sprintf("\n\t%-15s %s", "types", "Get details about a specific typing"),
)
fmt.Println(helpMessage)
}
Expand All @@ -91,6 +92,7 @@ func runCLI(args []string) int {

commands := map[string]func(){
"pokemon": cmd.PokemonCommand,
"natures": cmd.NaturesCommand,
"types": cmd.TypesCommand,
}

Expand All @@ -111,10 +113,11 @@ func runCLI(args []string) int {
errMessage := errorBorder.Render(
errorColor.Render("Error!"),
fmt.Sprintf("\n\t%-15s", fmt.Sprintf("'%s' is not a valid command.\n", command)),
styleBold.Render("\nAvailable Commands:"),
fmt.Sprintf("\n\t%-15s %s", "pokemon", "Get details of a specific Pokémon"),
fmt.Sprintf("\n\t%-15s %s", "types", "Get details of a specific typing\n"),
fmt.Sprintf("\nAlso run %s for more info!", styleBold.Render("[poke-cli -h]")),
styleBold.Render("\nCommands:"),
fmt.Sprintf("\n\t%-15s %s", "natures", "Get details about Pokémon natures"),
fmt.Sprintf("\n\t%-15s %s", "pokemon", "Get details about a specific Pokémon"),
fmt.Sprintf("\n\t%-15s %s", "types", "Get details about a specific typing"),
fmt.Sprintf("\n\nAlso run %s for more info!", styleBold.Render("poke-cli -h")),
)
fmt.Printf("%s\n", errMessage)
return 1
Expand Down
111 changes: 57 additions & 54 deletions cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,6 @@ func TestCurrentVersion(t *testing.T) {
}
}

var ansiRegex = regexp.MustCompile(`\x1b\[[0-9;]*m`)

func captureOutput(f func()) string {
var buf bytes.Buffer
stdout := os.Stdout
Expand All @@ -82,6 +80,8 @@ func captureOutput(f func()) string {
}

func stripANSI(input string) string {
// Regular expression to match ANSI escape sequences
ansiRegex := regexp.MustCompile(`\x1b\[[0-9;]*m`)
return ansiRegex.ReplaceAllString(input, "")
}

Expand All @@ -95,67 +95,70 @@ func TestRunCLI(t *testing.T) {
{
name: "No Arguments",
args: []string{},
expectedOutput: "╭────────────────────────────────────────────────────────╮\n" +
"│Welcome! This tool displays data related to Pokémon! │\n" +
"│ │\n" +
"│ USAGE: │\n" +
"│ poke-cli [flag] │\n" +
"│ poke-cli <command> [flag] │\n" +
"│ poke-cli <command> <subcommand> [flag] │\n" +
"│ │\n" +
"│ FLAGS: │\n" +
"│ -h, --help Shows the help menu │\n" +
"│ -l, --latest Prints the latest version available │\n" +
"│ -v, --version Prints the current version │\n" +
"│ │\n" +
"│ AVAILABLE COMMANDS: │\n" +
"│ pokemon Get details of a specific Pokémon │\n" +
"│ types Get details of a specific typing │\n" +
"╰────────────────────────────────────────────────────────╯\n",
expectedOutput: "╭─────────────────────────────────────────────────────────╮\n" +
"│Welcome! This tool displays data related to Pokémon! │\n" +
"│ │\n" +
"│ USAGE: │\n" +
"│ poke-cli [flag] │\n" +
"│ poke-cli <command> [flag] │\n" +
"│ poke-cli <command> <subcommand> [flag] │\n" +
"│ │\n" +
"│ FLAGS: │\n" +
"│ -h, --help Shows the help menu │\n" +
"│ -l, --latest Prints the latest version available │\n" +
"│ -v, --version Prints the current version │\n" +
"│ │\n" +
"│ COMMANDS: │\n" +
"│ natures Get details about Pokémon natures │\n" +
"│ pokemon Get details about a specific Pokémon │\n" +
"│ types Get details about a specific typing │\n" +
"╰─────────────────────────────────────────────────────────╯\n",
expectedCode: 0,
},
{
name: "Help Flag Short",
args: []string{"-h"},
expectedOutput: "╭────────────────────────────────────────────────────────╮\n" +
"│Welcome! This tool displays data related to Pokémon! │\n" +
"│ │\n" +
"│ USAGE: │\n" +
"│ poke-cli [flag] │\n" +
"│ poke-cli <command> [flag] │\n" +
"│ poke-cli <command> <subcommand> [flag] │\n" +
"│ │\n" +
"│ FLAGS: │\n" +
"│ -h, --help Shows the help menu │\n" +
"│ -l, --latest Prints the latest version available │\n" +
"│ -v, --version Prints the current version │\n" +
"│ │\n" +
"│ AVAILABLE COMMANDS: │\n" +
"│ pokemon Get details of a specific Pokémon │\n" +
"│ types Get details of a specific typing │\n" +
"╰────────────────────────────────────────────────────────╯\n",
expectedOutput: "╭─────────────────────────────────────────────────────────╮\n" +
"│Welcome! This tool displays data related to Pokémon! │\n" +
"│ │\n" +
"│ USAGE: │\n" +
"│ poke-cli [flag] │\n" +
"│ poke-cli <command> [flag] │\n" +
"│ poke-cli <command> <subcommand> [flag] │\n" +
"│ │\n" +
"│ FLAGS: │\n" +
"│ -h, --help Shows the help menu │\n" +
"│ -l, --latest Prints the latest version available │\n" +
"│ -v, --version Prints the current version │\n" +
"│ │\n" +
"│ COMMANDS: │\n" +
"│ natures Get details about Pokémon natures │\n" +
"│ pokemon Get details about a specific Pokémon │\n" +
"│ types Get details about a specific typing │\n" +
"╰─────────────────────────────────────────────────────────╯\n",
expectedCode: 0,
},
{
name: "Help Flag Long",
args: []string{"--help"},
expectedOutput: "╭────────────────────────────────────────────────────────╮\n" +
"│Welcome! This tool displays data related to Pokémon! │\n" +
"│ │\n" +
"│ USAGE: │\n" +
"│ poke-cli [flag] │\n" +
"│ poke-cli <command> [flag] │\n" +
"│ poke-cli <command> <subcommand> [flag] │\n" +
"│ │\n" +
"│ FLAGS: │\n" +
"│ -h, --help Shows the help menu │\n" +
"│ -l, --latest Prints the latest version available │\n" +
"│ -v, --version Prints the current version │\n" +
"│ │\n" +
"│ AVAILABLE COMMANDS: │\n" +
"│ pokemon Get details of a specific Pokémon │\n" +
"│ types Get details of a specific typing │\n" +
"╰────────────────────────────────────────────────────────╯\n",
expectedOutput: "╭─────────────────────────────────────────────────────────╮\n" +
"│Welcome! This tool displays data related to Pokémon! │\n" +
"│ │\n" +
"│ USAGE: │\n" +
"│ poke-cli [flag] │\n" +
"│ poke-cli <command> [flag] │\n" +
"│ poke-cli <command> <subcommand> [flag] │\n" +
"│ │\n" +
"│ FLAGS: │\n" +
"│ -h, --help Shows the help menu │\n" +
"│ -l, --latest Prints the latest version available │\n" +
"│ -v, --version Prints the current version │\n" +
"│ │\n" +
"│ COMMANDS: │\n" +
"│ natures Get details about Pokémon natures │\n" +
"│ pokemon Get details about a specific Pokémon │\n" +
"│ types Get details about a specific typing │\n" +
"╰─────────────────────────────────────────────────────────╯\n",
expectedCode: 0,
},
{
Expand All @@ -167,7 +170,7 @@ func TestRunCLI(t *testing.T) {
{
name: "Latest Flag",
args: []string{"-l"},
expectedOutput: "Latest Docker image version: v0.9.2\nLatest release tag: v0.9.2\n",
expectedOutput: "Latest Docker image version: v0.9.3\nLatest release tag: v0.9.3\n",
expectedCode: 0,
},
}
Expand Down
Loading
Loading