- 移除 TodoItem 中的 priority、created_at 和 updated_at 字段 - 强制每个任务都必须有唯一 id,且由用户负责生成 - 修改合并模式逻辑,merge=true 下保留未提及的旧任务 - 支持已完成和已取消任务重新激活(状态改回 pending 或 in_progress) - 禁止 in_progress 状态退回到 pending,必须标记为 completed 或 cancelled - 优化状态转换校验,允许特定状态间合法切换 - 简化任务变更消息,移除详细的新增/更新/移除统计 - 更新文档和示例,明确 id 必须由用户生成和使用 - 修复和补充测试,增强状态转换和合并模式验证 - 调整任务时间戳生成逻辑,统一使用当前时间及索引 - 该变更提供更合理的任务状态机械及管理模式,提升稳定性和易用性
136 lines
3.9 KiB
Markdown
136 lines
3.9 KiB
Markdown
|
||
# drive +export
|
||
|
||
> **前置条件:** 先阅读 [`../lark-shared/SKILL.md`](../../lark-shared/SKILL.md) 了解认证、全局参数和安全规则。
|
||
|
||
把 `doc` / `docx` / `sheet` / `bitable` / `slides` 导出到本地文件。这个 shortcut 内置有限轮询:
|
||
|
||
- 如果导出任务在轮询窗口内完成,会直接下载到本地目录
|
||
- 如果轮询结束仍未完成,会返回 `ticket`、`ready=false`、`timed_out=true` 和 `next_command`
|
||
- 后续继续查结果时,改用 `drive +task_result --scenario export`
|
||
- 拿到 `file_token` 后,改用 `drive +export-download`
|
||
|
||
## 命令
|
||
|
||
```bash
|
||
# 导出新版文档为 pdf,默认保存到当前目录
|
||
lark-cli drive +export \
|
||
--token "<DOCX_TOKEN>" \
|
||
--doc-type docx \
|
||
--file-extension pdf
|
||
|
||
# 导出旧版文档为 docx
|
||
lark-cli drive +export \
|
||
--token "<DOC_TOKEN>" \
|
||
--doc-type doc \
|
||
--file-extension docx
|
||
|
||
# 导出 docx 为 markdown(Lark-flavored Markdown)
|
||
# 注意:markdown 只支持 docx
|
||
lark-cli drive +export \
|
||
--token "<DOCX_TOKEN>" \
|
||
--doc-type docx \
|
||
--file-extension markdown
|
||
|
||
# 导出电子表格为 xlsx
|
||
lark-cli drive +export \
|
||
--token "<SHEET_TOKEN>" \
|
||
--doc-type sheet \
|
||
--file-extension xlsx \
|
||
--output-dir ./exports
|
||
|
||
# 导出幻灯片为 pptx
|
||
lark-cli drive +export \
|
||
--token "<SLIDES_TOKEN>" \
|
||
--doc-type slides \
|
||
--file-extension pptx \
|
||
--output-dir ./exports
|
||
|
||
# 导出幻灯片为 pdf
|
||
lark-cli drive +export \
|
||
--token "<SLIDES_TOKEN>" \
|
||
--doc-type slides \
|
||
--file-extension pdf \
|
||
--output-dir ./exports
|
||
|
||
# 指定本地文件名(会按导出格式自动补扩展名)
|
||
lark-cli drive +export \
|
||
--token "<DOCX_TOKEN>" \
|
||
--doc-type docx \
|
||
--file-extension pdf \
|
||
--file-name "weekly-report.pdf" \
|
||
--output-dir ./exports
|
||
|
||
# 导出电子表格或多维表格为 csv 时,必须传 sub_id
|
||
lark-cli drive +export \
|
||
--token "<SHEET_OR_BITABLE_TOKEN>" \
|
||
--doc-type "<sheet|bitable>" \
|
||
--file-extension csv \
|
||
--sub-id "<SUB_ID>" \
|
||
--output-dir ./exports
|
||
|
||
# 导出多维表格为 .base 快照(只支持 bitable)
|
||
lark-cli drive +export \
|
||
--token "<BITABLE_TOKEN>" \
|
||
--doc-type bitable \
|
||
--file-extension base \
|
||
--output-dir ./exports
|
||
|
||
# 允许覆盖已存在文件
|
||
lark-cli drive +export \
|
||
--token "<DOCX_TOKEN>" \
|
||
--doc-type docx \
|
||
--file-extension pdf \
|
||
--overwrite
|
||
```
|
||
|
||
## 参数
|
||
|
||
| 参数 | 必填 | 说明 |
|
||
|------|------|------|
|
||
| `--token` | 是 | 源文档 token |
|
||
| `--doc-type` | 是 | 源文档类型:`doc` / `docx` / `sheet` / `bitable` / `slides` |
|
||
| `--file-extension` | 是 | 导出格式:`docx` / `pdf` / `xlsx` / `csv` / `markdown` / `base` / `pptx` |
|
||
| `--sub-id` | 条件必填 | 当 `sheet` / `bitable` 导出为 `csv` 时必填 |
|
||
| `--file-name` | 否 | 覆盖默认本地文件名;如未带扩展名,会按 `--file-extension` 自动补齐 |
|
||
| `--output-dir` | 否 | 本地输出目录,默认当前目录 |
|
||
| `--overwrite` | 否 | 覆盖已存在文件 |
|
||
|
||
## 关键约束
|
||
|
||
- `markdown` 只支持 `docx`
|
||
- `base` 只支持 `bitable`
|
||
- `pptx` 只支持 `slides`
|
||
- `slides` 支持导出为 `pptx` / `pdf`
|
||
- `sheet` / `bitable` 导出为 `csv` 时必须带 `--sub-id`
|
||
- shortcut 内部固定有限轮询:最多 10 次,每次间隔 5 秒
|
||
- 轮询超时不是失败;会返回 `ticket`、`timed_out=true` 和 `next_command`,供后续继续查询
|
||
|
||
## 推荐续跑方式
|
||
|
||
```bash
|
||
# 第一步:先尝试直接导出
|
||
lark-cli drive +export \
|
||
--token "<DOCX_TOKEN>" \
|
||
--doc-type docx \
|
||
--file-extension pdf \
|
||
--file-name "weekly-report.pdf"
|
||
|
||
# 如果返回 ready=false / timed_out=true,再继续查
|
||
lark-cli drive +task_result \
|
||
--scenario export \
|
||
--ticket "<TICKET>" \
|
||
--file-token "<DOCX_TOKEN>"
|
||
|
||
# 查到 file_token 后下载
|
||
lark-cli drive +export-download \
|
||
--file-token "<EXPORTED_FILE_TOKEN>" \
|
||
--file-name "weekly-report.pdf" \
|
||
--output-dir ./exports
|
||
```
|
||
|
||
## 参考
|
||
|
||
- [lark-drive](../SKILL.md) -- 云空间(云盘/云存储)全部命令
|
||
- [lark-shared](../../lark-shared/SKILL.md) -- 认证和全局参数
|