Skip to content

GuillaumeFalourd/poc-cli-golang

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

12 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

poc-cli-golang

POC of a CLI project using Golang inspired from this article.

๐Ÿ“‘ Requirements

  • Golang installed (go1.15 or newer)
  • Cobra library (go get -u github.com/spf13/cobra/cobra)
  • Any code editor of your choice

โš™๏ธ Setup & Update

At the repository root run:

go install my-cli

Then, the my-cli command should be recognized on your terminal.

Note: If my-cli is not recognized by the terminal, please run:

export PATH=$PATH:$(go env GOPATH)/bin

...or check your $HOME/go/bin directory if the my-cli bin is there).

๐Ÿš€ Run

Login

Will return SUCCESS if username and password flags are the same.

my-cli login -u="username" -p = "password"

Add

Will return the sum of all numbers used as arguments.

my-cli add 1 2 3 4

Add Even (Add sub-command)

Will return the sum of all even numbers used as arguments.

my-cli add even 1 2 3 4

Add Odd (Add sub-command)

Will return the sum of all odd numbers used as arguments.

my-cli add odd 1 2 3 4

Create

Will create something with the specified arg <name> using the flag --env-from:

my-cli create <name> --env-from="dev"