GitCode CLI - Command line tool for GitCode
Project description
GitCode CLI
GitCode 命令行工具,为 GitCode 用户提供便捷的命令行操作体验。
安装
从源码构建
前置要求:
- Go 1.22+
# 克隆仓库
git clone https://gitcode.com/gitcode-cli/cli.git
cd cli
# 构建
go build -o gc ./cmd/gc
# 安装到用户目录
mkdir -p ~/.local/bin
mv gc ~/.local/bin/
export PATH="$HOME/.local/bin:$PATH"
Linux 包管理器
DEB (Debian/Ubuntu):
# 从 Releases 下载 .deb 包
wget https://gitcode.com/gitcode-cli/cli/releases/download/v0.2.5/gc_0.2.5_amd64.deb
# 安装
sudo dpkg -i gc_0.2.5_amd64.deb
RPM (RHEL/CentOS/Fedora):
# 从 Releases 下载 .rpm 包
wget https://gitcode.com/gitcode-cli/cli/releases/download/v0.2.5/gc-0.2.5-1.x86_64.rpm
# 安装
sudo rpm -i gc-0.2.5-1.x86_64.rpm
PyPI (跨平台)
# 使用 pip 安装
pip install gitcode-cli
# 或指定版本
pip install gitcode-cli==0.2.5
规划中的安装方式
以下安装方式正在开发中:
- 预编译二进制文件(Linux/macOS/Windows)
- Homebrew (macOS/Linux)
- Scoop (Windows)
- Docker 镜像
快速开始
认证
方式一:设置环境变量(推荐)
# 设置 Token 环境变量
export GC_TOKEN="your_gitcode_token"
# 或使用备用变量名
export GITCODE_TOKEN="your_gitcode_token"
# 添加到 shell 配置文件(永久生效)
echo 'export GC_TOKEN="your_gitcode_token"' >> ~/.bashrc
source ~/.bashrc
方式二:交互式登录
# 交互式登录(需输入 Token)
gc auth login
# 使用 Token 参数登录
gc auth login --token YOUR_TOKEN
获取 Token:
- 登录 GitCode
- 进入 设置 -> 私人令牌
- 点击"生成新令牌",选择所需权限
- 复制生成的 Token
验证认证:
# 查看认证状态
gc auth status
📖 完整命令指南: 查看 COMMANDS.md 获取所有命令的详细使用说明和示例。
命令示例
仓库操作
# 克隆仓库
gc repo clone owner/repo
# 创建新仓库
gc repo create my-repo --public
# 查看仓库信息
gc repo view owner/repo
# Fork 仓库
gc repo fork owner/repo
# 删除仓库
gc repo delete owner/repo
Issue 管理
# 创建 Issue
gc issue create --title "Bug report" --body "Description"
# 列出 Issues
gc issue list --state open
# 查看 Issue 详情
gc issue view 123
# 关闭 Issue
gc issue close 123
# 重开 Issue
gc issue reopen 123
# 添加评论
gc issue comment 123 --body "Comment text"
# 管理 Issue 标签
gc issue label 123 --add bug,enhancement
Pull Request 管理
# 创建 PR
gc pr create --title "New feature" --base main
# 列出 PR
gc pr list --state open
# 查看 PR 详情
gc pr view 456
# 检出 PR 分支
gc pr checkout 456
# 合并 PR
gc pr merge 456 --squash
# 关闭/重开 PR
gc pr close 456
gc pr reopen 456
# 编辑 PR
gc pr edit 456 --title "New title"
gc pr edit 456 --draft true
# 代码检视
gc pr review 456 --approve
gc pr review 456 --request
gc pr review 456 --comment "Review comment"
Release 管理
# 创建 Release(建议包含 --notes 参数)
gc release create v1.0.0 --title "Version 1.0" --notes "Release notes"
# 列出 Releases
gc release list -R owner/repo
# 查看 Release 详情
gc release view v1.0.0 -R owner/repo
# 上传资产到 Release
gc release upload v1.0.0 app.zip -R owner/repo
gc release upload v1.0.0 file1.tar.gz file2.rpm -R owner/repo
# 下载 Release 资产
gc release download v1.0.0 -R owner/repo
gc release download v1.0.0 app.zip -R owner/repo -o ./downloads/
# 删除 Release
gc release delete v1.0.0 -R owner/repo
注意:
release create命令建议包含--notes参数,否则可能返回错误。
功能特性
| 功能 | 描述 |
|---|---|
| 🔐 认证管理 | Token 认证、多账户支持、安全存储 |
| 📦 仓库操作 | 克隆、创建、Fork、查看、删除 |
| 🐛 Issue 管理 | 创建、列表、查看、关闭、重开、评论 |
| 🔀 PR 管理 | 创建、列表、查看、检出、合并、关闭 |
| 👀 代码检视 | 批准、请求修改、添加评论 |
| 🏷️ 标签管理 | 创建、列表、删除 |
| 🎯 里程碑管理 | 创建、列表、查看、删除 |
| 🚀 Release 管理 | 创建、列表、查看、上传资产、下载资产 |
命令概览
gc <command> <subcommand> [flags]
Commands:
auth 认证管理 (login, logout, status, token)
repo 仓库操作 (clone, create, list, view, fork, delete)
issue Issue 管理 (create, list, view, close, reopen, comment)
pr PR 管理 (create, list, view, checkout, merge, close, reopen, review, diff, ready)
label 标签管理 (create, list, delete)
milestone 里程碑管理 (create, list, view, delete)
release Release 管理 (create, list, view, upload, download, delete)
version 显示版本信息
配置
配置文件位置: ~/.config/gc/config.yaml
# 默认主机
host: gitcode.com
# Git 协议
git_protocol: https
# 默认编辑器
editor: vim
# 分页器
pager: less
环境变量
| 变量 | 描述 |
|---|---|
GC_TOKEN |
认证 Token |
GITCODE_TOKEN |
备用 Token |
GC_HOST |
默认主机 |
NO_COLOR |
禁用颜色输出 |
Shell 补全
# Bash
gc completion bash > /etc/bash_completion.d/gc
source ~/.bashrc
# Zsh
gc completion zsh > "${fpath[1]}/_gc"
source ~/.zshrc
# Fish
gc completion fish > ~/.config/fish/completions/gc.fish
source ~/.config/fish/config.fish
文档
- 命令指南 - 所有命令的详细使用说明和示例
- 版本发布 - 发布流程和产物说明
- 打包发布 - DEB/RPM 包构建和发布流程
- 贡献指南 - 开发和发布流程
- 安全策略 - 敏感信息保护和安全规范
- CLAUDE.md - AI 辅助开发指南
- 需求文档 - 完整需求规格和里程碑规划
技术栈
| 组件 | 技术 |
|---|---|
| 语言 | Go 1.22+ |
| 命令框架 | Cobra |
| 配置格式 | YAML |
| 目标平台 | Linux, macOS, Windows |
开发
# 克隆仓库
git clone https://gitcode.com/gitcode-cli/cli.git
cd gitcode-cli
# 安装依赖
make deps
# 构建
make build
# 运行测试
make test
# 代码检查
make lint
# 运行
make run
贡献
欢迎贡献代码!请查看 贡献指南。
许可证
致谢
本项目参考了 GitHub CLI 的设计与实现,感谢 GitHub 团队的开源贡献。
相关链接
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file gitcode_cli-0.2.8.tar.gz.
File metadata
- Download URL: gitcode_cli-0.2.8.tar.gz
- Upload date:
- Size: 15.1 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
96b54ba458e6d8e690526fbb159bb64bf527652230b952546a03ee4cf3889703
|
|
| MD5 |
a5244a936af1dbe388fce2679730b137
|
|
| BLAKE2b-256 |
ffea1d2b274a3d6e4a13a91e93a3fa1c637f10b1d9cd07ddf2d823688ed607a5
|
Provenance
The following attestation bundles were made for gitcode_cli-0.2.8.tar.gz:
Publisher:
release.yml on kerer-ai/gitcode-cli
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
gitcode_cli-0.2.8.tar.gz -
Subject digest:
96b54ba458e6d8e690526fbb159bb64bf527652230b952546a03ee4cf3889703 - Sigstore transparency entry: 1169661036
- Sigstore integration time:
-
Permalink:
kerer-ai/gitcode-cli@7aa8495187c7d990be293f3252e29ce83495f5ca -
Branch / Tag:
refs/tags/v0.2.8 - Owner: https://github.com/kerer-ai
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@7aa8495187c7d990be293f3252e29ce83495f5ca -
Trigger Event:
push
-
Statement type:
File details
Details for the file gitcode_cli-0.2.8-py3-none-any.whl.
File metadata
- Download URL: gitcode_cli-0.2.8-py3-none-any.whl
- Upload date:
- Size: 15.2 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f991e7e9ed764d031e1c57ded16a6b77d7e8524bdd3df79ac3488d36587618a1
|
|
| MD5 |
0829bedb2fd5d613f89345758870ec4e
|
|
| BLAKE2b-256 |
e04b2dba8a0b09e139d54537aa04f3836e5a73b7a44ee1dec122a7406694e2fd
|
Provenance
The following attestation bundles were made for gitcode_cli-0.2.8-py3-none-any.whl:
Publisher:
release.yml on kerer-ai/gitcode-cli
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
gitcode_cli-0.2.8-py3-none-any.whl -
Subject digest:
f991e7e9ed764d031e1c57ded16a6b77d7e8524bdd3df79ac3488d36587618a1 - Sigstore transparency entry: 1169661162
- Sigstore integration time:
-
Permalink:
kerer-ai/gitcode-cli@7aa8495187c7d990be293f3252e29ce83495f5ca -
Branch / Tag:
refs/tags/v0.2.8 - Owner: https://github.com/kerer-ai
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@7aa8495187c7d990be293f3252e29ce83495f5ca -
Trigger Event:
push
-
Statement type: