Skip to content

Commit 1413337

Browse files
Merge pull request #84 from digitalghost-dev/0.9.1
0.9.1
2 parents 18350ce + ff5846d commit 1413337

File tree

12 files changed

+103
-19
lines changed

12 files changed

+103
-19
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ on:
2424
branches:
2525
- main
2626
env:
27-
VERSION_NUMBER: 'v0.9.0'
27+
VERSION_NUMBER: 'v0.9.1'
2828
DOCKERHUB_REGISTRY_NAME: 'digitalghostdev/poke-cli'
2929
AWS_REGION: 'us-west-2'
3030

.github/workflows/coverage.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Coverage Report
2+
3+
on:
4+
pull_request:
5+
types: [opened, reopened, synchronize]
6+
7+
jobs:
8+
tests:
9+
runs-on: ubuntu-22.04
10+
steps:
11+
- name: Checkout
12+
uses: actions/checkout@v4
13+
14+
- name: Set up Go
15+
uses: actions/setup-go@v5
16+
with:
17+
go-version: 1.23
18+
19+
- name: Install dependencies
20+
run: |
21+
go install .
22+
23+
- name: Run coverage
24+
run: go test ./... -race -coverprofile=coverage.txt -covermode=atomic
25+
26+
- name: Upload coverage to Codecov
27+
uses: codecov/codecov-action@v5
28+
with:
29+
token: ${{ secrets.CODECOV_ORG_TOKEN }}

.github/workflows/go_test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
- name: Set up Go
1515
uses: actions/setup-go@v5
1616
with:
17-
go-version: 1.21
17+
go-version: 1.23
1818

1919
- name: Install dependencies
2020
run: |

.gitignore

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,14 @@
77
*.DS_Store
88
*.idea
99
.dccache
10+
dist/
1011

1112
# Test binary, built with `go test -c`
1213
*.test
1314

1415
# Output of the go coverage tool, specifically when used with LiteIDE
1516
*.out
17+
codecov*
1618

1719
# Dependency directories (remove the comment below to include it)
1820
# vendor/
@@ -22,5 +24,4 @@ go.work
2224
go.work.sum
2325

2426
# env file
25-
.env
26-
dist/
27+
.env

.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.9.0
17+
- -s -w -X main.version=v0.9.1
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.9.0" -o poke-cli .
11+
RUN go build -ldflags "-X main.version=v0.9.1" -o poke-cli .
1212

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

LICENSE.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) [2024] [Christian Sanchez]
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<img height="250" width="350" src="https://cdn.simpleicons.org/pokemon/FFCC00" 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.9.0?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.9.1?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">
@@ -68,15 +68,15 @@ _Use a Docker Image_
6868
* Necessary.
6969

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

7474
### Go Install
7575
_If you have Go already, install the executable yourself_
7676

7777
1. Run the following command:
7878
```bash
79-
go install github.com/digitalghost-dev/poke-cli@v0
79+
go install github.com/digitalghost-dev/poke-cli@latest
8080
```
8181
2. The tool is ready to use!
8282
---

cli_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ func TestRunCLI(t *testing.T) {
110110
{
111111
name: "Latest Flag",
112112
args: []string{"-l"},
113-
expectedOutput: "Latest Docker image version: v0.8.0\nLatest release tag: v0.8.0\n",
113+
expectedOutput: "Latest Docker image version: v0.9.0\nLatest release tag: v0.9.0\n",
114114
expectedCode: 0,
115115
},
116116
}

cmd/validateargs.go

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ func handleHelpFlag(args []string) {
1818

1919
// ValidatePokemonArgs validates the command line arguments
2020
func ValidatePokemonArgs(args []string) error {
21-
2221
handleHelpFlag(args)
2322

23+
// Check if the number of arguments is less than 3
2424
if len(args) < 3 {
2525
errMessage := errorBorder.Render(
2626
errorColor.Render("Error!"),
@@ -31,23 +31,53 @@ func ValidatePokemonArgs(args []string) error {
3131
return fmt.Errorf("%s", errMessage)
3232
}
3333

34+
// Check if there are too many arguments
3435
if len(args) > 6 {
35-
errMessage := errorBorder.Render(errorColor.Render("Error!"), "\nToo many arguments")
36+
errMessage := errorBorder.Render(
37+
errorColor.Render("Error!"),
38+
"\nToo many arguments",
39+
)
3640
return fmt.Errorf("%s", errMessage)
3741
}
3842

43+
// Validate each argument after the Pokémon's name
3944
if len(args) > 3 {
4045
for _, arg := range args[3:] {
46+
// Check for single `-` or `--` which are invalid
47+
if arg == "-" || arg == "--" {
48+
errorTitle := errorColor.Render("Error!")
49+
errorString := fmt.Sprintf(
50+
"\nInvalid argument '%s'. Single '-' or '--' is not allowed.\nPlease use valid flags.",
51+
arg,
52+
)
53+
finalErrorMessage := errorTitle + errorString
54+
renderedError := errorBorder.Render(finalErrorMessage)
55+
return fmt.Errorf("%s", renderedError)
56+
}
57+
58+
// Check if the argument starts with a flag prefix but is invalid
4159
if arg[0] != '-' {
4260
errorTitle := errorColor.Render("Error!")
43-
errorString := fmt.Sprintf("\nInvalid argument '%s'. Only flags are allowed after declaring a Pokémon's name", arg)
61+
errorString := fmt.Sprintf(
62+
"\nInvalid argument '%s'.\nOnly flags are allowed after declaring a Pokémon's name",
63+
arg,
64+
)
4465
finalErrorMessage := errorTitle + errorString
4566
renderedError := errorBorder.Render(finalErrorMessage)
4667
return fmt.Errorf("%s", renderedError)
4768
}
4869
}
4970
}
5071

72+
// Add a check for invalid Pokémon names (e.g., names starting with `-`)
73+
if len(args[2]) > 0 && args[2][0] == '-' {
74+
errMessage := errorBorder.Render(
75+
errorColor.Render("Error!"),
76+
"\nPokémon not found. Perhaps a typo in the name?",
77+
)
78+
return fmt.Errorf("%s", errMessage)
79+
}
80+
5181
return nil
5282
}
5383

0 commit comments

Comments
 (0)