CLI 命令参考¶
共 24 个子命令,基于 click 框架,通过
certflow <command> [options]调用。 入口:src/certflow/cli/__init__.py、__main__.py、base_command.py。 统一初始化:base_command.py的get_cli_db_manager()/get_cli_session()(含 WebDAV 同步)。
命令索引¶
命令 |
功能 |
状态 |
|---|---|---|
|
导入销售计划 Excel |
✅ |
|
自动编号 |
✅ |
|
生成合格证记录 |
✅ |
|
导出 Excel |
✅ |
|
导出 Access(仅 Windows) |
🟡 |
|
快速查询 |
✅ |
|
多维度统计 |
✅ |
|
标记已发货 |
✅ |
|
记录发货信息 |
✅ |
|
设置编号年月前缀 |
✅ |
|
批量更新字段 |
✅ |
|
导入材质牌号 |
✅ |
|
导入合格证清单 |
✅ |
|
复制合同信息到合格证字段 |
✅ |
|
检查数据一致性 |
✅ |
|
清理重复记录 |
✅ |
|
回填供货类型 |
✅ |
|
数据库备份 |
✅ |
|
WebDAV 同步(push/pull/status) |
✅ |
|
数据库重置 |
✅ |
|
BOM 零件牌号管理 |
✅ |
|
生成报告(质保书/试压/材质) |
✅ |
|
监控文件夹自动导入 |
✅ |
|
Web 界面(占位,未实现) |
🔴 |
详细参数¶
import-sales-plan¶
certflow import-sales-plan <file> [--scope all|new] [--month YYYYMM] \
[--header-row N] [--start-row N] [--end-row N] \
[--col-map k=v,...] [--collision skip|overwrite|merge] [--dry-run]
对齐 GUI 全部参数。
auto-number¶
certflow auto-number [--month YYYYMM] [--prefix PREFIX] [--filter "..."]
print-cert¶
certflow print-cert [--filter "product_code not null and cert_done=0"]
生成合格证:将已编号(product_code 非空)且未生成合格证的记录写入 certificate 表。
export-excel¶
certflow export-excel --filter "status=已发货" --out ./output/plan.xlsx
export-access¶
certflow export-access --out ./SignDB.mdb
🟡 依赖 Windows Access 驱动,非 Windows 不可用。
quick-query¶
certflow quick-query --status 待生产 --month 202608
stats¶
certflow stats --by status # 按状态
certflow stats --by customer # 按客户
certflow stats --by supply_type # 按供货类型
certflow stats --by month # 按月份
mark-shipped / record-shipment¶
certflow mark-shipped --plan-no CF2026080001
certflow record-shipment --plan-no CF2026080001 --date 2026-08-04 --carrier SF
set-year-month¶
certflow set-year-month 202608
batch-update¶
certflow batch-update --field supply_type --value make --filter "status=待生产"
grade-import¶
certflow grade-import material_grades.csv
import-certs¶
certflow import-certs cert_list.xlsx
copy-cert-info¶
certflow copy-cert-info --plan-no CF2026080001
check-consistency¶
certflow check-consistency
clean-duplicates¶
certflow clean-duplicates [--dry-run]
backfill-supply-type¶
certflow backfill-supply-type
db-backup¶
certflow db-backup --out ./backup/certflow_$(date +%Y%m%d).db
db-sync¶
certflow db-sync push
certflow db-sync pull
certflow db-sync status
db-reset¶
certflow db-reset --force
certflow db-reset --baseline ./database/baseline.db --force
bom¶
certflow bom list
certflow bom add <part_no> <grade>
certflow bom remove <part_no>
report-gen¶
certflow report-gen --type warranty --sample 10
certflow report-gen --type pressure --plan-no CF2026080001
certflow report-gen --type material --filter "..."
watch¶
certflow watch --dir ./incoming --pattern "*.xlsx"
watchdog 监控目录,新文件出现自动导入。
serve 🔴¶
certflow serve --host 127.0.0.1 --port 8080
未实现:certflow.web 模块不存在,输出"Web 模块尚未实现"。详见 08-todo.md T0-1。
全局选项¶
选项 |
说明 |
|---|---|
|
显示帮助 |
|
详细日志(部分命令支持) |
所有命令共享 get_cli_db_manager() 初始化的数据库(含 WebDAV 同步),确保 CLI 与 GUI 数据一致。