介绍
# Craft CLI
与 Craft.do 文档、块和任务进行交互。
## 安装
1. 安装:将 `scripts/craft` 复制到 `~/bin/craft` 并设置为可执行 2. 从 Craft 获取 API URL:Settings > Integrations > Craft Connect > Create Link 3. 设置环境变量:`export CRAFT_API_URL='https://connect.craft.do/links/YOUR_LINK/api/v1'`
将其添加到 Shell 配置文件中以持久化保存。
## 命令
### 文档
```bash craft folders # List all folders craft docs [location] # List documents (unsorted, trash, templates, daily_notes) craft doc <id> # Get document content by ID craft daily [date] # Get daily note (today, yesterday, YYYY-MM-DD) craft search <term> # Search across documents craft create-doc "Title" [folderId] # Create new document ```
### 块
```bash craft add-block <docId> "markdown" # Add block to document craft add-to-daily "markdown" [date] # Add to daily note (default: today) craft update-block <blockId> "markdown" # Update existing block craft delete-block <blockId>... # Delete block(s) ```
### 任务
```bash craft tasks [scope] # List tasks (inbox, active, upcoming, logbook) craft add-task "text" [scheduleDate] # Add task to inbox craft complete-task <id> # Mark task as done craft delete-task <id> # Delete task ```
### 集合
```bash craft collections # List all collections craft collection-items <id> # Get items from collection ```
## 注意事项
- Markdown 内容作为参数传递;如有需要,请对引号进行转义 - 日期:`today`、`yesterday` 或 `YYYY-MM-DD` - 任务范围:`inbox`(默认)、`active`、`upcoming`、`logbook` - 文档位置:`unsorted`、`trash`、`templates`、`daily_notes`