@@ -17,21 +17,55 @@ BootCS 命令行工具 - 用于代码检查和提交
1717
1818## 安装
1919
20- ### 推荐方式:从 GitHub 安装
20+ ### 🐳 推荐方式:Docker 版(无需配置环境)
2121
22- \`\`\` bash
22+ Docker 版开箱即用,包含 C/Python/Java 完整开发环境,与评测环境完全一致。
23+
24+ ** 一键安装:**
25+
26+ ``` bash
27+ curl -fsSL https://raw.githubusercontent.com/bootcs-cn/bootcs-cli/main/scripts/install-docker.sh | bash
28+ ```
29+
30+ ** 手动安装:**
31+
32+ ``` bash
33+ # 1. 拉取镜像
34+ docker pull ghcr.io/bootcs-cn/bootcs-cli:latest
35+
36+ # 2. 下载 wrapper 脚本
37+ sudo curl -fsSL -o /usr/local/bin/bootcs \
38+ https://raw.githubusercontent.com/bootcs-cn/bootcs-cli/main/scripts/bootcs-wrapper.sh
39+ sudo chmod +x /usr/local/bin/bootcs
40+ ```
41+
42+ 安装后,使用方式与本地安装完全一致:
43+
44+ ``` bash
45+ bootcs login # 登录(仅需一次)
46+ bootcs check cs50/hello # 检查代码
47+ bootcs submit cs50/hello # 提交代码
48+ ```
49+
50+ > 💡 ** 提示** : Docker 版会自动持久化凭证到 ` ~/.bootcs/ ` ,登录一次即可长期使用。
51+
52+ ### 本地安装:pip
53+
54+ 如果你更喜欢本地安装(需要自行配置 C/Python 环境):
55+
56+ ``` bash
2357pip install git+https://github.com/bootcs-cn/bootcs-cli.git
24- \`\`\ `
58+ `` `
2559
2660### 开发模式安装
2761
28- \`\`\ ` bash
62+ `` `bash
2963git clone https://github.com/bootcs-cn/bootcs-cli.git
3064cd bootcs-cli
3165python -m venv .venv
3266source .venv/bin/activate
3367pip install -e .
34- \`\`\ `
68+ `` `
3569
3670## 快速开始
3771
@@ -46,126 +80,148 @@ bootcs login
4680### 2. 检查代码
4781
4882\`\`\` bash
83+
4984# 进入你的代码目录
85+
5086cd ~ /projects/hello
5187
5288# 检查代码(自动下载 checks,自动检测语言)
89+
5390bootcs check cs50/hello
5491
5592# 指定语言
93+
5694bootcs check cs50/hello -L python
5795
5896# 强制更新 checks
97+
5998bootcs check cs50/hello -u
6099
61100# 输出 JSON 格式
101+
62102bootcs check cs50/hello --output json
63103\`\`\`
64104
65105### 3. 提交代码
66106
67107\`\`\` bash
108+
68109# 提交代码到 BootCS 平台
110+
69111bootcs submit cs50/hello
70112
71113# 跳过确认
114+
72115bootcs submit cs50/hello -y
73116
74117# 自定义提交消息
118+
75119bootcs submit cs50/hello -m "Fix bug"
76120\`\`\`
77121
78122### 4. 管理缓存
79123
80124\`\`\` bash
125+
81126# 查看已缓存的 checks
127+
82128bootcs cache list
83129
84130# 清空所有缓存
131+
85132bootcs cache clear
86133
87134# 清空特定课程的缓存
135+
88136bootcs cache clear cs50
89137\`\`\`
90138
91139### 5. 账户管理
92140
93141\`\`\` bash
142+
94143# 查看当前登录用户
144+
95145bootcs whoami
96146
97147# 登出
148+
98149bootcs logout
99150\`\`\`
100151
101152## 命令参考
102153
103- | 命令 | 说明 |
104- | ---------------------- | ---------------- |
105- | \` bootcs --version\` | 显示版本号 |
106- | \` bootcs --help\` | 显示帮助信息 |
107- | \` bootcs login\` | 使用 GitHub 登录 |
108- | \` bootcs logout\` | 登出 |
109- | \` bootcs whoami\` | 显示当前登录用户 |
110- | \` bootcs check <slug >\` | 检查代码 |
111- | \` bootcs submit <slug >\` | 提交代码 |
112- | \` bootcs cache <action >\` | 管理缓存 |
154+ | 命令 | 说明 |
155+ | ------------------------- | ---------------- |
156+ | \` bootcs --version\` | 显示版本号 |
157+ | \` bootcs --help\` | 显示帮助信息 |
158+ | \` bootcs login\` | 使用 GitHub 登录 |
159+ | \` bootcs logout\` | 登出 |
160+ | \` bootcs whoami\` | 显示当前登录用户 |
161+ | \` bootcs check <slug >\` | 检查代码 |
162+ | \` bootcs submit <slug >\` | 提交代码 |
163+ | \` bootcs cache <action >\` | 管理缓存 |
113164
114165### check 命令选项
115166
116- | 选项 | 说明 |
117- | ----------------------- | ----------------------------- |
118- | \` -L, --language LANG\` | 指定语言 (自动检测如不指定) |
119- | \` -u, --update\` | 强制更新 checks |
120- | \` --output [ ansi| json] \` | 输出格式 (默认: ansi) |
121- | \` --log\` | 显示详细日志 |
122- | \` --target NAME\` | 只运行指定的检查 |
123- | \` --local PATH\` | 使用本地检查脚本目录 |
167+ | 选项 | 说明 |
168+ | ----------------------- | --------------------------- | ------------------- -- |
169+ | \` -L, --language LANG\` | 指定语言 (自动检测如不指定) |
170+ | \` -u, --update\` | 强制更新 checks |
171+ | \` --output [ ansi | json] \` | 输出格式 (默认: ansi) |
172+ | \` --log\` | 显示详细日志 |
173+ | \` --target NAME\` | 只运行指定的检查 |
174+ | \` --local PATH\` | 使用本地检查脚本目录 |
124175
125176### submit 命令选项
126177
127- | 选项 | 说明 |
128- | ------------------- | ----- ------------------- |
129- | \` -L, --language\` | 指定语言 (自动检测) |
130- | \` -m, --message MSG\` | 自定义提交消息 |
131- | \` -y, --yes\` | 跳过确认提示 |
132- | \` --local PATH\` | 使用本地配置目录 |
178+ | 选项 | 说明 |
179+ | --------------------- | ------------------- |
180+ | \` -L, --language\` | 指定语言 (自动检测) |
181+ | \` -m, --message MSG\` | 自定义提交消息 |
182+ | \` -y, --yes\` | 跳过确认提示 |
183+ | \` --local PATH\` | 使用本地配置目录 |
133184
134185### cache 命令选项
135186
136- | 选项 | 说明 |
137- | ----------------- | - ----------------------- |
138- | \` list\` | 列出所有缓存的 checks |
139- | \` clear [ slug] \` | 清空缓存 (可选指定课程) |
140- | \` -L, --language\` | 指定语言 |
187+ | 选项 | 说明 |
188+ | ------------------ | ----------------------- |
189+ | \` list\` | 列出所有缓存的 checks |
190+ | \` clear [ slug] \` | 清空缓存 (可选指定课程) |
191+ | \` -L, --language\` | 指定语言 |
141192
142193## 语言自动检测
143194
144195CLI 会根据当前目录的文件自动检测编程语言:
145196
146- | 文件扩展名 | 检测为 |
147- | ------------| --------|
148- | \` .c\` , \` .h\` | C |
149- | \` .py\` | Python |
197+ | 文件扩展名 | 检测为 |
198+ | ----------------- | ---------- |
199+ | \` .c\` , \` .h\` | C |
200+ | \` .py\` | Python |
150201| \` .js\` , \` .mjs\` | JavaScript |
151- | \` .go\` | Go |
152- | \` .rs\` | Rust |
202+ | \` .go\` | Go |
203+ | \` .rs\` | Rust |
153204
154205如果目录有多种语言的文件,会选择文件数量最多的语言。
155206
156207## 开发
157208
158209\`\`\` bash
210+
159211# 安装开发依赖
212+
160213pip install -e ".[ dev] "
161214
162215# 运行单元测试
216+
163217pytest tests/unit/ -v
164218
165219# 运行所有测试
220+
166221pytest
167222
168223# 代码格式化
224+
169225black bootcs/
170226ruff check bootcs/
171227\`\`\`
@@ -175,34 +231,34 @@ ruff check bootcs/
175231\`\`\`
176232bootcs-cli/
177233├── bootcs/
178- │ ├── __ init __ .py # 版本信息
179- │ ├── __ main __ .py # CLI 入口
180- │ ├── auth/ # 认证模块
181- │ │ ├── credentials.py
182- │ │ └── device_flow.py
183- │ ├── api/ # API 客户端
184- │ │ ├── client.py
185- │ │ ├── submit.py
186- │ │ └── checks.py # 远程 checks 管理
187- │ ├── check/ # 检查模块 (基于 check50)
188- │ │ ├── _ api.py
189- │ │ ├── runner.py
190- │ │ └── c.py
191- │ └── lib50/ # 工具库 (基于 lib50)
192- │ ├── config.py
193- │ └── ...
234+ │ ├── ** init ** .py # 版本信息
235+ │ ├── ** main ** .py # CLI 入口
236+ │ ├── auth/ # 认证模块
237+ │ │ ├── credentials.py
238+ │ │ └── device_flow.py
239+ │ ├── api/ # API 客户端
240+ │ │ ├── client.py
241+ │ │ ├── submit.py
242+ │ │ └── checks.py # 远程 checks 管理
243+ │ ├── check/ # 检查模块 (基于 check50)
244+ │ │ ├── \ _ api.py
245+ │ │ ├── runner.py
246+ │ │ └── c.py
247+ │ └── lib50/ # 工具库 (基于 lib50)
248+ │ ├── config.py
249+ │ └── ...
194250├── tests/
195- │ └── unit/ # 单元测试
251+ │ └── unit/ # 单元测试
196252├── pyproject.toml
197253└── README.md
198254\`\`\`
199255
200256## 环境变量
201257
202- | 变量 | 说明 | 默认值 |
203- | ------------------ | ---------------- | ----------------------- |
204- | \` BOOTCS_API_URL\` | API 服务地址 | \` https://api.bootcs.cn\` |
205- | \` BOOTCS_CHECKS_PATH\` | 本地 checks 路径 (评测环境用) | - |
258+ | 变量 | 说明 | 默认值 |
259+ | ---------------------- | ----------------------------- | -- ----------------------- |
260+ | \` BOOTCS_API_URL\` | API 服务地址 | \` https://api.bootcs.cn\` |
261+ | \` BOOTCS_CHECKS_PATH\` | 本地 checks 路径 (评测环境用) | - |
206262
207263## 许可证
208264
0 commit comments