git-cnb, a Git command-line extension tool specifically for cnb, allows you to quickly view cnb information in the terminal using git commands, such as repositories, users, issues, PRs, releases, etc.
Binary installation [Recommended]
curl https://cnb.cool/looc/git-cnb/-/git/raw/main/install.sh -sSfL | sh
Install using Golang
go install cnb.cool/looc/git-cnb@latest
Use it as a Git extension subcommand.
NOTE: Since it needs to call CNB's OpenAPI to get related information, you need to configure the CNB Token using environment variables. The token permissions depend on the features used, you can configure token permissions as needed.
$ export CNB_TOKEN="... your token ..."
If you need to operate multiple CNB instances with different domains, you can configure different CNB_TOKENs for each domain. The rule is CNB_TOKEN_{domain-without-dot} (environment variables don't support ., so we use the domain name without . as suffix to distinguish, e.g.
$ export CNB_TOKEN_cnbcool=".. your token ..." #cnb.cool $ export CNB_TOKEN_cnbdev=".. your token ..." #cnb.dev
The TOKEN requires at least the following permissions:
repo-notes:r
repo-pr:r
repo-code:rw
repo-basic-info:r
account-profile:r
$ git cnb -h
Available Commands:
commit Manage commits
completion Generate the autocompletion script for the specified shell
download Download raw files from repository
groups Manage gruops
help Help about any command
info Print information of this repo
issue Manage issue
knowledges Manage knowledges
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
Flags:
--domain string domain, eg: cnb.cool, default: cnb.cool
-h, --help help for git-cnb
--repo string repo name, eg: looc/git-cnb
git-cnb also provides some cnb plugins, and you can use the plugins to quickly complete some complex tasks.