cli-anything-drawio
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinesecli-anything-drawio
cli-anything-drawio
A CLI harness for Draw.io — create, edit, and export diagrams from the command line.
一款面向Draw.io的CLI工具——可通过命令行创建、编辑和导出图表。
Installation
安装
This CLI is installed as part of the cli-anything-drawio package:
bash
pip install cli-anything-drawioPrerequisites:
- Python 3.10+
- drawio must be installed on your system
本CLI作为cli-anything-drawio包的一部分进行安装:
bash
pip install cli-anything-drawio前置要求:
- Python 3.10+
- 系统中必须安装drawio
Usage
使用方法
Basic Commands
基础命令
bash
undefinedbash
undefinedShow help
显示帮助信息
cli-anything-drawio --help
cli-anything-drawio --help
Start interactive REPL mode
启动交互式REPL模式
cli-anything-drawio
cli-anything-drawio
Create a new project
创建新项目
cli-anything-drawio project new -o project.json
cli-anything-drawio project new -o project.json
Run with JSON output (for agent consumption)
以JSON格式输出(供Agent调用)
cli-anything-drawio --json project info -p project.json
undefinedcli-anything-drawio --json project info -p project.json
undefinedREPL Mode
REPL模式
When invoked without a subcommand, the CLI enters an interactive REPL session:
bash
cli-anything-drawio当不指定子命令调用时,CLI会进入交互式REPL会话:
bash
cli-anything-drawioEnter commands interactively with tab-completion and history
交互式输入命令,支持自动补全和历史记录
undefinedundefinedCommand Groups
命令组
Project
项目管理
Project management: new, open, save, info.
| Command | Description |
|---|---|
| Create a new blank diagram |
| Open an existing .drawio project file |
| Save the current project |
| Show detailed project information |
| Print the raw XML of the current project |
| List available page size presets |
项目管理命令:新建、打开、保存、查看信息。
| 命令 | 描述 |
|---|---|
| 创建新的空白图表 |
| 打开现有的.drawio项目文件 |
| 保存当前项目 |
| 显示详细的项目信息 |
| 打印当前项目的原始XML内容 |
| 列出可用的页面尺寸预设 |
Shape
图形操作
Shape operations: add, remove, move, resize, style.
| Command | Description |
|---|---|
| Add a shape to the diagram |
| Remove a shape by ID |
| List all shapes on a page |
| Update a shape's label text |
| Move a shape to new coordinates |
| Resize a shape |
| Set a style property on a shape |
| Show detailed info about a shape |
| List all available shape types |
图形操作命令:添加、删除、移动、调整大小、设置样式。
| 命令 | 描述 |
|---|---|
| 向图表中添加图形 |
| 根据ID删除图形 |
| 列出页面上的所有图形 |
| 更新图形的标签文本 |
| 将图形移动到新坐标 |
| 调整图形大小 |
| 设置图形的样式属性 |
| 显示图形的详细信息 |
| 列出所有可用的图形类型 |
Connect
连接线操作
Connector operations: add, remove, style.
| Command | Description |
|---|---|
| Add a connector between two shapes |
| Remove a connector by ID |
| Update a connector's label |
| Set a style property on a connector |
| List all connectors on a page |
| List available edge styles |
连接线操作命令:添加、删除、设置样式。
| 命令 | 描述 |
|---|---|
| 在两个图形之间添加连接线 |
| 根据ID删除连接线 |
| 更新连接线的标签 |
| 设置连接线的样式属性 |
| 列出页面上的所有连接线 |
| 列出可用的边线样式 |
Page
页面操作
Page operations: add, remove, rename, list.
| Command | Description |
|---|---|
| Add a new page |
| Remove a page by index |
| Rename a page |
| List all pages |
页面操作命令:添加、删除、重命名、列出。
| 命令 | 描述 |
|---|---|
| 添加新页面 |
| 根据索引删除页面 |
| 重命名页面 |
| 列出所有页面 |
Export
导出操作
Export operations: render to PNG, PDF, SVG.
| Command | Description |
|---|---|
| Export the diagram to a file |
| List available export formats |
导出操作命令:渲染为PNG、PDF、SVG格式。
| 命令 | 描述 |
|---|---|
| 将图表导出为文件 |
| 列出可用的导出格式 |
Session
会话管理
Session management: status, undo, redo.
| Command | Description |
|---|---|
| Show current session status |
| Undo the last operation |
| Redo the last undone operation |
| Save session state to disk |
| List all saved sessions |
会话管理命令:状态查看、撤销、重做。
| 命令 | 描述 |
|---|---|
| 显示当前会话状态 |
| 撤销上一次操作 |
| 重做上一次撤销的操作 |
| 将会话状态保存到磁盘 |
| 列出所有已保存的会话 |
Examples
示例
Create a New Project
创建新项目
Create a new drawio project file.
bash
cli-anything-drawio project new -o myproject.json创建新的drawio项目文件。
bash
cli-anything-drawio project new -o myproject.jsonOr with JSON output for programmatic use
或使用JSON格式输出供程序调用
cli-anything-drawio --json project new -o myproject.json
undefinedcli-anything-drawio --json project new -o myproject.json
undefinedInteractive REPL Session
交互式REPL会话
Start an interactive session with undo/redo support.
bash
cli-anything-drawio启动支持撤销/重做功能的交互式会话。
bash
cli-anything-drawioEnter commands interactively
交互式输入命令
Use 'help' to see available commands
使用'help'查看可用命令
Use 'undo' and 'redo' for history navigation
使用'undo'和'redo'导航操作历史
undefinedundefinedExport Project
导出项目
Export the project to a final output format.
bash
cli-anything-drawio --project myproject.json export render output.pdf --overwrite将项目导出为最终输出格式。
bash
cli-anything-drawio --project myproject.json export render output.pdf --overwriteState Management
状态管理
The CLI maintains session state with:
- Undo/Redo: Up to 50 levels of history
- Project persistence: Save/load project state as JSON
- Session tracking: Track modifications and changes
CLI通过以下方式维护会话状态:
- 撤销/重做:最多支持50级操作历史
- 项目持久化:以JSON格式保存/加载项目状态
- 会话跟踪:跟踪修改和变更
Output Formats
输出格式
All commands support dual output modes:
- Human-readable (default): Tables, colors, formatted text
- Machine-readable (flag): Structured JSON for agent consumption
--json
bash
undefined所有命令支持两种输出模式:
- 人类可读格式(默认):表格、彩色文本、格式化内容
- 机器可读格式(参数):结构化JSON,供Agent调用
--json
bash
undefinedHuman output
人类可读输出
cli-anything-drawio project info -p project.json
cli-anything-drawio project info -p project.json
JSON output for agents
供Agent调用的JSON输出
cli-anything-drawio --json project info -p project.json
undefinedcli-anything-drawio --json project info -p project.json
undefinedFor AI Agents
面向AI Agent的使用说明
When using this CLI programmatically:
- Always use flag for parseable output
--json - Check return codes - 0 for success, non-zero for errors
- Parse stderr for error messages on failure
- Use absolute paths for all file operations
- Verify outputs exist after export operations
当以编程方式使用本CLI时:
- 始终使用参数以获得可解析的输出
--json - 检查返回码 - 0表示成功,非0表示错误
- 解析stderr以获取失败时的错误信息
- 所有文件操作使用绝对路径
- 导出操作后验证输出文件是否存在
More Information
更多信息
- Full documentation: See README.md in the package
- Test coverage: See TEST.md in the package
- Methodology: See HARNESS.md in the cli-anything-plugin
- 完整文档:查看包中的README.md
- 测试覆盖率:查看包中的TEST.md
- 实现方法:查看cli-anything-plugin中的HARNESS.md
Version
版本
1.0.0
1.0.0