@@ -11,177 +11,151 @@ BootCS 命令行工具 - 用于代码检查和提交
1111- ✅ ** 代码检查** - 本地运行检查脚本验证代码正确性
1212- ✅ ** GitHub 登录** - 使用 Device Flow 进行 GitHub 认证
1313- ✅ ** 代码提交** - 将代码提交到 BootCS 平台进行评测
14+ - ✅ ** 远程 Checks** - 自动从服务器下载检查脚本
15+ - ✅ ** 多语言支持** - 自动检测 C、Python 等编程语言
16+ - ✅ ** 缓存管理** - 本地缓存检查脚本,提高效率
1417
15- ## 许可证
18+ ## 安装
1619
17- 本项目基于 GPL-3.0 许可证发布,遵循 check50/lib50 的许可证要求。
20+ ### 推荐方式:从 GitHub 安装
1821
19- ## 安装
22+ \`\`\` bash
23+ pip install git+https://github.com/bootcs-cn/bootcs-cli.git
24+ \`\`\`
2025
21- ### 方式一:Python 安装
26+ ### 开发模式安装
2227
23- ``` bash
24- # 开发模式安装
28+ \`\`\` bash
2529git clone https://github.com/bootcs-cn/bootcs-cli.git
2630cd bootcs-cli
2731python -m venv .venv
2832source .venv/bin/activate
2933pip install -e .
30- ```
31-
32- ### 方式二:Docker 镜像
33-
34- ``` bash
35- # 拉取基础镜像
36- docker pull ghcr.io/bootcs-cn/bootcs-cli:latest
37-
38- # 拉取包含 CS50 检查脚本的镜像
39- docker pull ghcr.io/bootcs-cn/bootcs-cli:cs50
40- ```
34+ \`\`\`
4135
4236## 快速开始
4337
4438### 1. 登录
4539
46- `` `bash
40+ \`\`\ ` bash
4741bootcs login
48- `` `
42+ \`\`\ `
4943
5044按照提示访问 GitHub 并输入验证码完成登录。
5145
5246### 2. 检查代码
5347
54- `` `bash
55- # 检查当前目录的代码
56- bootcs check cs50/hello --local /path/to/checks /hello
48+ \`\`\ ` bash
49+ # 进入你的代码目录
50+ cd ~ /projects /hello
5751
58- # 输出 JSON 格式
59- bootcs check cs50/hello --local /path/to/checks --output json
52+ # 检查代码(自动下载 checks,自动检测语言)
53+ bootcs check cs50/hello
54+
55+ # 指定语言
56+ bootcs check cs50/hello -L python
6057
61- # 显示详细日志
62- bootcs check cs50/hello --local /path/to/checks --log
63- ```
58+ # 强制更新 checks
59+ bootcs check cs50/hello -u
60+
61+ # 输出 JSON 格式
62+ bootcs check cs50/hello --output json
63+ \`\`\`
6464
6565### 3. 提交代码
6666
67- `` `bash
67+ \`\`\ ` bash
6868# 提交代码到 BootCS 平台
69- bootcs submit cs50/hello --local /path/to/checks/hello
69+ bootcs submit cs50/hello
7070
7171# 跳过确认
72- bootcs submit cs50/hello --local /path/to/checks/hello - y
72+ bootcs submit cs50/hello -y
7373
7474# 自定义提交消息
75- bootcs submit cs50/hello --local /path/to/checks/hello -m " Fix bug"
76- ```
75+ bootcs submit cs50/hello -m "Fix bug"
76+ \`\`\`
77+
78+ ### 4. 管理缓存
7779
78- ### 4. 账户管理
80+ \`\`\` bash
81+ # 查看已缓存的 checks
82+ bootcs cache list
7983
80- ``` bash
84+ # 清空所有缓存
85+ bootcs cache clear
86+
87+ # 清空特定课程的缓存
88+ bootcs cache clear cs50
89+ \`\`\`
90+
91+ ### 5. 账户管理
92+
93+ \`\`\` bash
8194# 查看当前登录用户
8295bootcs whoami
8396
8497# 登出
8598bootcs logout
86- `` `
99+ \`\`\ `
87100
88101## 命令参考
89102
90103| 命令 | 说明 |
91104| ---------------------- | ---------------- |
92- | ` bootcs --version ` | 显示版本号 |
93- | ` bootcs --help ` | 显示帮助信息 |
94- | ` bootcs login ` | 使用 GitHub 登录 |
95- | ` bootcs logout ` | 登出 |
96- | ` bootcs whoami ` | 显示当前登录用户 |
97- | ` bootcs check <slug> ` | 检查代码 |
98- | ` bootcs submit <slug> ` | 提交代码 |
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 >\` | 管理缓存 |
99113
100114### check 命令选项
101115
102- | 选项 | 说明 |
103- | ----------------------- | --------------------- |
104- | ` --local PATH ` | 指定本地检查脚本目录 |
105- | ` --output [ansi\|json] ` | 输出格式 (默认: ansi) |
106- | ` --log ` | 显示详细日志 |
107- | ` --target NAME ` | 只运行指定的检查 |
116+ | 选项 | 说明 |
117+ | ----------------------- | ----------------------------- |
118+ | \` -L, --language LANG\` | 指定语言 (自动检测如不指定) |
119+ | \` -u, --update\` | 强制更新 checks |
120+ | \` --output [ ansi| json] \` | 输出格式 (默认: ansi) |
121+ | \` --log\` | 显示详细日志 |
122+ | \` --target NAME\` | 只运行指定的检查 |
123+ | \` --local PATH\` | 使用本地检查脚本目录 |
108124
109125### submit 命令选项
110126
111- | 选项 | 说明 |
112- | ------------------- | --------------------------------------- |
113- | ` --local PATH ` | 指定本地检查脚本目录 (用于获取文件列表) |
114- | ` -m, --message MSG ` | 自定义提交消息 |
115- | ` -y, --yes ` | 跳过确认提示 |
116-
117- ## Docker 使用
118-
119- ### 本地自测
120-
121- 使用 Docker 镜像可以在本地快速进行代码检查,无需安装 Python 环境:
122-
123- ``` bash
124- # 使用基础镜像检查代码
125- docker run --rm -v $( pwd) :/workspace -v /path/to/checks:/checks \
126- ghcr.io/bootcs-cn/bootcs-cli:latest \
127- check course-cs50/hello --local /checks/hello
128-
129- # 使用课程专用镜像(已包含检查脚本)
130- docker run --rm -v $( pwd) :/workspace \
131- ghcr.io/bootcs-cn/bootcs-cli:cs50 \
132- check course-cs50/hello --local /checks/hello
133- ```
134-
135- ### GitHub Actions 评测
136-
137- 在 GitHub Actions 中使用 Docker 镜像进行自动评测:
138-
139- ``` yaml
140- # .github/workflows/evaluate.yml
141- name : Evaluate
142-
143- on :
144- push :
145- branches : [main]
146-
147- jobs :
148- evaluate :
149- runs-on : ubuntu-latest
150- container :
151- image : ghcr.io/bootcs-cn/bootcs-cli:cs50
152- steps :
153- - uses : actions/checkout@v4
154- - name : Run check
155- run : |
156- bootcs check course-cs50/hello --local /checks/hello --output json > result.json
157- - name : Upload result
158- uses : actions/upload-artifact@v4
159- with :
160- name : result
161- path : result.json
162- ` ` `
163-
164- ### 使用评测脚本
165-
166- 镜像中包含 ` bootcs-evaluate.sh` 脚本,用于标准化评测:
167-
168- ` ` ` bash
169- # 脚本用法
170- bootcs-evaluate.sh <slug> <checks_path> <student_code_path>
171-
172- # 示例
173- docker run --rm \
174- -v $(pwd):/workspace \
175- -v /path/to/output:/output \
176- ghcr.io/bootcs-cn/bootcs-cli:cs50 \
177- bootcs-evaluate.sh course-cs50/hello /checks/hello /workspace
178-
179- # 结果输出到 /output/result.json
180- ` ` `
127+ | 选项 | 说明 |
128+ | ------------------- | ------------------------ |
129+ | \` -L, --language\` | 指定语言 (自动检测) |
130+ | \` -m, --message MSG\` | 自定义提交消息 |
131+ | \` -y, --yes\` | 跳过确认提示 |
132+ | \` --local PATH\` | 使用本地配置目录 |
133+
134+ ### cache 命令选项
135+
136+ | 选项 | 说明 |
137+ | ----------------- | ------------------------ |
138+ | \` list\` | 列出所有缓存的 checks |
139+ | \` clear [ slug] \` | 清空缓存 (可选指定课程) |
140+ | \` -L, --language\` | 指定语言 |
141+
142+ ## 语言自动检测
143+
144+ CLI 会根据当前目录的文件自动检测编程语言:
145+
146+ | 文件扩展名 | 检测为 |
147+ | ------------| --------|
148+ | \` .c\` , \` .h\` | C |
149+ | \` .py\` | Python |
150+ | \` .js\` , \` .mjs\` | JavaScript |
151+ | \` .go\` | Go |
152+ | \` .rs\` | Rust |
153+
154+ 如果目录有多种语言的文件,会选择文件数量最多的语言。
181155
182156## 开发
183157
184- ` ` ` bash
158+ \`\`\ ` bash
185159# 安装开发依赖
186160pip install -e ".[ dev] "
187161
@@ -194,11 +168,11 @@ pytest
194168# 代码格式化
195169black bootcs/
196170ruff check bootcs/
197- ` ` `
171+ \`\`\ `
198172
199173## 项目结构
200174
201- `` `
175+ \`\`\ `
202176bootcs-cli/
203177├── bootcs/
204178│ ├── __ init__ .py # 版本信息
@@ -208,33 +182,31 @@ bootcs-cli/
208182│ │ └── device_flow.py
209183│ ├── api/ # API 客户端
210184│ │ ├── client.py
211- │ │ └── submit.py
185+ │ │ ├── submit.py
186+ │ │ └── checks.py # 远程 checks 管理
212187│ ├── check/ # 检查模块 (基于 check50)
213188│ │ ├── _ api.py
214189│ │ ├── runner.py
215- │ │ ├── c.py
216- │ │ └── ...
190+ │ │ └── c.py
217191│ └── lib50/ # 工具库 (基于 lib50)
218192│ ├── config.py
219193│ └── ...
220194├── tests/
221- │ ├── unit/ # 单元测试
222- │ └── check50/ # check50 测试用例
195+ │ └── unit/ # 单元测试
223196├── pyproject.toml
224- ├── README.md
225- └── ROADMAP.md
226- ```
197+ └── README.md
198+ \`\`\`
227199
228200## 环境变量
229201
230- | 变量 | 说明 | 默认值 |
231- | ---------------- | ------------ | ----------------------- |
232- | `BOOTCS_API_URL` | API 服务地址 | `https://api.bootcs.cn` |
202+ | 变量 | 说明 | 默认值 |
203+ | ------------------ | ---------------- | ----------------------- |
204+ | \` BOOTCS_API_URL\` | API 服务地址 | \` https://api.bootcs.cn\` |
205+ | \` BOOTCS_CHECKS_PATH\` | 本地 checks 路径 (评测环境用) | - |
233206
234- ## 文档
207+ ## 许可证
235208
236- - [设计文档](DESIGN.md)
237- - [落地路线图](ROADMAP.md)
209+ 本项目基于 GPL-3.0 许可证发布,遵循 check50/lib50 的许可证要求。
238210
239211## 致谢
240212
0 commit comments