README-zh.md

August 4, 2022 · View on GitHub

简介

GitHub release Github All Releases license Go Reference Coverage Status

这是一个用 Go 和 cobra 编写的 CLI 应用

📜 语言

English | 简体中文

🛠️ 安装

Homebrew

elliotxx/tap 有 MacOS 和 GNU/Linux 的预编译二进制版本可用:

brew install elliotxx/tap/go-cli-prototype

脚本安装

在 Linux 和 MacOS 环境中,go-cli-prototype 可以通过脚本一键安装:

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 或者其它感兴趣的用户可以直接在 Github Release 页面中下载二进制文件。

从源码构建

使用 Go 1.17+ 版本,你可以通过 go install 直接从源码安装 go-cli-prototype:

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

注意: 你将基于代码仓库最新的可用版本安装 go-cli-prototype,尽管主分支的最新提交应该始终是一个稳定和可用的版本,但这不是安装和使用 go-cli-prototype 的推荐方式。通过 go install 安装的 go-cli-prototype 版本输出将显示默认版本号(default-version)。

⚡ 使用

本地启动:

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

本地构建:

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

运行所有单元测试:

make test

全部可用的 Target:

$ 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