git-cnb, 一个 cnb 专属的 Git 命令行扩展工具, 可以使用 git 命令行的方式在终端快捷查看 cnb 的信息,比如仓库,用户,issue,pr,release 等等。
二进制安装 [荐]
curl https://cnb.cool/looc/git-cnb/-/git/raw/main/install.sh -sSfL | sh
使用 golang 安装
go install cnb.cool/looc/git-cnb@latest
作为 git 的一个扩展子命令行工具来使用。
NOTE: 由于需要调用 CNB 的 openapi 获取相关信息,所以需要使用环境变量来配置 CNB 的 Token, token 的权限取决于使用到的功能,可按需来配置 token 权限。
$ export CNB_TOKEN="... your token ..."
如果你同时需要操作多个域名不同的 CNB, 可以为每个域名配置不同的 CNB_TOKEN,规则为 CNB_TOKEN_{domain-without-dot}(环境变量不支持., 这里使用域名去掉.的后缀来区分,比如
$ export CNB_TOKEN_cnbcool=".. your token ..." #cnb.cool $ export CNB_TOKEN_cnbdev=".. your token ..." #cnb.dev
TOKEN至少需要如下权限:
repo-notes:r
repo-pr:r
repo-code:rw
repo-basic-info:r
account-profile:r
$ git cnb -h
Available Commands:
commit Manage commits
help Help about any command
info Print information of this repo
issue Manage issue
pull Manage pull requests
release Manage releases
stars Print star trend info of this repo
stats Print stats information of this repo
version Print the version number of git-cnb
NOTE: CNB OpenAPI 更新可能有延迟,请以实际情况为准
git cnb stats

git cnb stars

git cnb issue list

git cnb pull list

git cnb pull create
git cnb release asset-stats

git cnb release asset-clean --keep-days=1

git cnb commit asset-stats

git cnb commit asset-clean --keep-num=1
