Skip to content

elliotxx/go-cli-prototype

Repository files navigation

Introduction

GitHub release Github All Releases license Go Reference Coverage Status

This is a cli application with go and cobra.

📜 Language

English | 简体中文

🛠️ Intallation

Homebrew

The elliotxx/tap has macOS and GNU/Linux pre-built binaries available:

brew install elliotxx/tap/go-cli-prototype

Script

The go-cli-prototype can be installed on Linux and macOS with a small install script:

curl -sSf https://raw.githubusercontent.com/elliotxx/go-cli-prototype/master/scripts/install.sh | bash

Or

wget -qO- https://raw.githubusercontent.com/elliotxx/go-cli-prototype/master/scripts/install.sh | bash

Windows or otherwise interested users can download binaries directly from the GitHub Releases page.

Build from Source

Starting with Go 1.17, you can install go-cli-prototype from source using go install:

go install github.com/elliotxx/go-cli-prototype/cmd/go-cli-prototype@latest

NOTE: This will install go-cli-prototype based on the latest available code base. Even though the goal is that the latest commit on the main branch should always be a stable and usable version, this is not the recommended way to install and use go-cli-prototype. The version output will show go-cli-prototype version (default-version) for go install based builds.

⚡ Usage

Local startup:

$ go run cmd/go-cli-prototype/main.go -e hello
hello
$ go run cmd/go-cli-prototype/main.go -V
v0.1.3-9312a46c

Local build:

$ make build-all
$ ./build/darwin/go-cli-prototype -e hello
hello
$ ./build/darwin/go-cli-prototype -V      
v0.1.3-9312a46c

Run all unit tests:

make test

All targets:

$ make help
help                           This help message :)
test                           Run the tests
cover                          Generates coverage report
cover-html                     Generates coverage report and displays it in the browser
format                         Format source code
lint                           Lint, will not fix but sets exit code on error
lint-fix                       Lint, will try to fix errors and modify code
doc                            Start the documentation server with godoc
gen-version                    Update version
clean                          Clean build bundles
build-all                      Build all platforms
build-darwin                   Build for MacOS
build-linux                    Build for Linux
build-windows                  Build for Windows