Skip to content

Commit

Permalink
Merge pull request #36 from digitalghost-dev/0.4.3
Browse files Browse the repository at this point in the history
0.4.3
  • Loading branch information
digitalghost-dev authored Sep 22, 2024
2 parents e4b1e62 + c70ac0c commit 5e7875a
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 35 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
branches:
- main
env:
VERSION_NUMBER: 'v0.4.2'
VERSION_NUMBER: 'v0.4.3'
REGISTRY_NAME: digitalghostdev/poke-cli

jobs:
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ FROM golang:1.21-alpine3.19

WORKDIR /app

ENV TERM xterm-256color
ENV COLOR_OUTPUT true
ENV TERM=xterm-256color
ENV COLOR_OUTPUT=true

COPY . /app

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@ git clone https://github.com/digitalghost-dev/poke-cli.git
### Docker
Use a Docker Image instead:
```bash
docker run --rm -it digitalghostdev/poke-cli:v0.4.2 [command] [subcommand] [flag]
docker run --rm -it digitalghostdev/poke-cli:v0.4.3 [command] [subcommand] [flag]
```

## Usage
By running `poke-cli [-h | --help]`, it'll display information on how to use the tool.
```
Welcome! This tool displays data about a selected Pokémon in the terminal!
Welcome! This tool displays data related to Pokémon!
USAGE:
poke-cli [flag]
Expand Down
40 changes: 20 additions & 20 deletions cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,31 +9,31 @@ import (
"os"
)

func main() {
var styleBold = lipgloss.NewStyle().Bold(true)
var (
styleBold = lipgloss.NewStyle().Bold(true)
helpBorder = lipgloss.NewStyle().
BorderStyle(lipgloss.RoundedBorder()).
BorderForeground(lipgloss.Color("#FFCC00"))
)

func main() {
latestFlag := flag.Bool("latest", false, "Prints the program's latest Docker Image and Release versions.")
shortLatestFlag := flag.Bool("l", false, "Prints the program's latest Docker Image and Release versions.")

flag.Usage = func() {
fmt.Println("Welcome! This tool displays data about a selected Pokémon in the terminal!")

// Usage section
fmt.Println(styleBold.Render("\nUSAGE:"))
fmt.Println("\t", "poke-cli [flag]")
fmt.Println("\t", "poke-cli [command] [flag]")
fmt.Println("\t", "poke-cli [command] [subcommand] [flag]")

// Flags section
fmt.Println(styleBold.Render("\nFLAGS:"))
fmt.Println("\t", "-h, --help", "\t\t", "Shows the help menu")
fmt.Println("\t", "-l, --latest", "\t\t", "Prints the latest version of the program")
fmt.Print("\n")

// Commands section
fmt.Println(styleBold.Render("\nCOMMANDS"))
fmt.Println("\t", "pokemon", "\t\t", "Get details of a specific Pokémon")
fmt.Print("\n")
helpMessage := helpBorder.Render(
"Welcome! This tool displays data related to Pokémon!",
"\n\n", styleBold.Render("USAGE:"),
fmt.Sprintf("\n\t%-15s %s", "poke-cli [flag]", ""),
fmt.Sprintf("\n\t%-15s %s", "poke-cli [command] [flag]", ""),
fmt.Sprintf("\n\t%-15s %s", "poke-cli [command] [subcommand] [flag]", ""),
"\n\n", styleBold.Render("FLAGS:"),
fmt.Sprintf("\n\t%-15s %s", "-h, --help", "Shows the help menu"),
fmt.Sprintf("\n\t%-15s %s", "-l, --latest", "Prints the latest version of the program"),
"\n\n", styleBold.Render("AVAILABLE COMMANDS:"),
fmt.Sprintf("\n\t%-15s %s", "pokemon", "Get details of a specific Pokémon"),
)
fmt.Println(helpMessage)
}

flag.Parse()
Expand Down
19 changes: 19 additions & 0 deletions cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,25 @@ func TestCLI(t *testing.T) {
"╰──────────────────────────────────────────────────────────────╯\n",
expectedExit: 0,
},
{
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 of the program │\n" +
"│ │\n" +
"│ AVAILABLE COMMANDS: │\n" +
"│ pokemon Get details of a specific Pokémon │\n" +
"╰─────────────────────────────────────────────────────────────╯\n",
expectedExit: 0,
},
}

for _, test := range tests {
Expand Down
24 changes: 14 additions & 10 deletions cmd/pokemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,17 +58,21 @@ func ValidateArgs(args []string) error {
func PokemonCommand() {

flag.Usage = func() {
fmt.Println(
helpBorder.Render(styleBold.Render("USAGE:"), "\n\t", "poke-cli", styleBold.Render("pokemon"), "<pokemon-name>", "[flag]",
"\n\t", "Get details about a specific Pokémon",
"\n\t", "----------",
"\n\t", styleItalic.Render("Examples:"), "\t", "poke-cli pokemon bulbasaur",
"\n\t\t\t", "poke-cli pokemon flutter-mane --types",
"\n\t\t\t", "poke-cli pokemon excadrill -t -a",
"\n",
styleBold.Render("\nFLAGS:"), "\n\t", "-a, --abilities", "\t", "Prints out the Pokémon's abilities.",
"\n\t", "-t, --types", "\t\t", "Prints out the Pokémon's typing."),
helpMessage := helpBorder.Render(
styleBold.Render("USAGE:"),
fmt.Sprintf("\n\t%s %s %s %s", "poke-cli", styleBold.Render("pokemon"), "<pokemon-name>", "[flag]"),
fmt.Sprintf("\n\t%-30s", "Get details about a specific Pokémon"),
fmt.Sprintf("\n\t%-30s", "----------"),
fmt.Sprintf("\n\t%-30s", styleItalic.Render("Examples:\n")),
fmt.Sprintf("\n\t%-30s", "poke-cli pokemon bulbasaur"),
fmt.Sprintf("\n\t%-30s", "poke-cli pokemon flutter-mane --types"),
fmt.Sprintf("\n\t%-30s", "poke-cli pokemon excadrill -t -a"),
"\n\n",
styleBold.Render("FLAGS:"),
fmt.Sprintf("\n\t%-30s %s", "-a, --abilities", "Prints out the Pokémon's abilities."),
fmt.Sprintf("\n\t%-30s %s", "-t, --types", "Prints out the Pokémon's typing."),
)
fmt.Println(helpMessage)
}

flag.Parse()
Expand Down

0 comments on commit 5e7875a

Please sign in to comment.