https://github.com/elliotxx/go-cli-prototype
This is a cli application with go and cobra.
https://github.com/elliotxx/go-cli-prototype
cli cobra example go golang
Last synced: 6 months ago
JSON representation
This is a cli application with go and cobra.
- Host: GitHub
- URL: https://github.com/elliotxx/go-cli-prototype
- Owner: elliotxx
- License: mit
- Created: 2021-11-01T03:39:21.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2022-08-04T08:25:12.000Z (about 3 years ago)
- Last Synced: 2025-04-12T23:44:44.157Z (6 months ago)
- Topics: cli, cobra, example, go, golang
- Language: Shell
- Homepage:
- Size: 71.3 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README-zh.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
## 简介
[](https://github.com/elliotxx/go-cli-prototype/releases)
[](https://github.com/elliotxx/go-cli-prototype/releases)
[](https://github.com/elliotxx/go-cli-prototype/blob/master/LICENSE)
[](https://pkg.go.dev/github.com/elliotxx/go-cli-prototype)
[](https://coveralls.io/github/elliotxx/go-cli-prototype)> 这是一个用 Go 和 cobra 编写的 CLI 应用
## 📜 语言
[English](https://github.com/elliotxx/go-cli-prototype/blob/master/README.md) | [简体中文](https://github.com/elliotxx/go-cli-prototype/blob/master/README-zh.md)
## 🛠️ 安装
### Homebrew
`elliotxx/tap` 有 MacOS 和 GNU/Linux 的预编译二进制版本可用:
```
brew install elliotxx/tap/go-cli-prototype
```### 脚本安装
在 Linux 和 MacOS 环境中,`go-cli-prototype` 可以通过脚本一键安装:
```bash
curl -sSf https://raw.githubusercontent.com/elliotxx/go-cli-prototype/master/scripts/install.sh | bash
```Or:
```bash
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
```