Skip to content

Commit

Permalink
Merge pull request #50 from digitalghost-dev/0.6.2
Browse files Browse the repository at this point in the history
0.6.2
  • Loading branch information
digitalghost-dev authored Oct 7, 2024
2 parents 7c70854 + 5db02db commit c56b4d5
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ on:
branches:
- main
env:
VERSION_NUMBER: 'v0.6.1'
VERSION_NUMBER: 'v0.6.2'
REGISTRY_NAME: digitalghostdev/poke-cli

jobs:
Expand Down
4 changes: 2 additions & 2 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.6.1?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.6.2?arch=arm64&style=flat-square&logo=docker&logoColor=FFCC00&labelColor=EEE&color=FFCC00" alt="docker-image-size">
</div>

<div align="center">
Expand Down Expand Up @@ -38,7 +38,7 @@ _Taskfile can build the executable for you_
_Use a Docker Image_

```bash
docker run --rm -it digitalghostdev/poke-cli:v0.6.0 [command] [subcommand] [flag]
docker run --rm -it digitalghostdev/poke-cli:v0.6.2 [command] [subcommand] [flag]
```

### Go Build
Expand Down
5 changes: 0 additions & 5 deletions cmd/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,6 @@ func TypesCommand() {
os.Exit(1)
}

if len(args) == 3 && (args[2] == "-h" || args[2] == "--help") {
flag.Usage()
return
}

columns := []table.Column{
{Title: "Type", Width: 16},
}
Expand Down
25 changes: 20 additions & 5 deletions cmd/validateargs.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package cmd
import (
"flag"
"fmt"
"os"
)

// ValidatePokemonArgs validates the command line arguments
Expand All @@ -23,8 +24,8 @@ func ValidatePokemonArgs(args []string) error {
if arg[0] != '-' {
errorTitle := errorColor.Render("Error!")
errorString := fmt.Sprintf("\nInvalid argument '%s'. Only flags are allowed after declaring a Pokémon's name", arg)
formattedString := errorTitle + errorString
renderedError := errorBorder.Render(formattedString)
finalErrorMessage := errorTitle + errorString
renderedError := errorBorder.Render(finalErrorMessage)
return fmt.Errorf("%s", renderedError)
}
}
Expand All @@ -45,10 +46,24 @@ func ValidateTypesArgs(args []string) error {
return fmt.Errorf("%s", errMessage)
}

// Check if there are exactly 3 arguments and the third argument is neither '-h' nor '--help'
// If true, return an error message since only '-h' and '--help' are allowed after 'types'
if len(args) == 3 && (args[2] != "-h" && args[2] != "--help") {
errMessage := errorBorder.Render("Error! The only currently available options\nafter [types] command is '-h' or '--help'")
return fmt.Errorf("%s", errMessage)
}
errorTitle := errorColor.Render("Error!")
errorString := "\nThe only currently available options\nafter [types] command are '-h' or '--help'"
finalErrorMessage := errorTitle + errorString
renderedError := errorBorder.Render(finalErrorMessage)
return fmt.Errorf("%s", renderedError)

// Check if there are exactly 3 arguments and the third argument is either '-h' or '--help'
// If true, display the usage information
} else if len(args) == 3 && (args[2] == "-h" || args[2] == "--help") {
flag.Usage()

// Only call os.Exit if not in test mode
if flag.Lookup("test.v") == nil {
os.Exit(0)
}
}
return nil
}

0 comments on commit c56b4d5

Please sign in to comment.