cli-anything-drawio

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

cli-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-drawio
Prerequisites:
  • 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
undefined
bash
undefined

Show 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
undefined
cli-anything-drawio --json project info -p project.json
undefined

REPL Mode

REPL模式

When invoked without a subcommand, the CLI enters an interactive REPL session:
bash
cli-anything-drawio
当不指定子命令调用时,CLI会进入交互式REPL会话:
bash
cli-anything-drawio

Enter commands interactively with tab-completion and history

交互式输入命令,支持自动补全和历史记录

undefined
undefined

Command Groups

命令组

Project

项目管理

Project management: new, open, save, info.
CommandDescription
new
Create a new blank diagram
open
Open an existing .drawio project file
save
Save the current project
info
Show detailed project information
xml
Print the raw XML of the current project
presets
List available page size presets
项目管理命令:新建、打开、保存、查看信息。
命令描述
new
创建新的空白图表
open
打开现有的.drawio项目文件
save
保存当前项目
info
显示详细的项目信息
xml
打印当前项目的原始XML内容
presets
列出可用的页面尺寸预设

Shape

图形操作

Shape operations: add, remove, move, resize, style.
CommandDescription
add
Add a shape to the diagram
remove
Remove a shape by ID
list
List all shapes on a page
label
Update a shape's label text
move
Move a shape to new coordinates
resize
Resize a shape
style
Set a style property on a shape
info
Show detailed info about a shape
types
List all available shape types
图形操作命令:添加、删除、移动、调整大小、设置样式。
命令描述
add
向图表中添加图形
remove
根据ID删除图形
list
列出页面上的所有图形
label
更新图形的标签文本
move
将图形移动到新坐标
resize
调整图形大小
style
设置图形的样式属性
info
显示图形的详细信息
types
列出所有可用的图形类型

Connect

连接线操作

Connector operations: add, remove, style.
CommandDescription
add
Add a connector between two shapes
remove
Remove a connector by ID
label
Update a connector's label
style
Set a style property on a connector
list
List all connectors on a page
styles
List available edge styles
连接线操作命令:添加、删除、设置样式。
命令描述
add
在两个图形之间添加连接线
remove
根据ID删除连接线
label
更新连接线的标签
style
设置连接线的样式属性
list
列出页面上的所有连接线
styles
列出可用的边线样式

Page

页面操作

Page operations: add, remove, rename, list.
CommandDescription
add
Add a new page
remove
Remove a page by index
rename
Rename a page
list
List all pages
页面操作命令:添加、删除、重命名、列出。
命令描述
add
添加新页面
remove
根据索引删除页面
rename
重命名页面
list
列出所有页面

Export

导出操作

Export operations: render to PNG, PDF, SVG.
CommandDescription
render
Export the diagram to a file
formats
List available export formats
导出操作命令:渲染为PNG、PDF、SVG格式。
命令描述
render
将图表导出为文件
formats
列出可用的导出格式

Session

会话管理

Session management: status, undo, redo.
CommandDescription
status
Show current session status
undo
Undo the last operation
redo
Redo the last undone operation
save-state
Save session state to disk
list
List all saved sessions
会话管理命令:状态查看、撤销、重做。
命令描述
status
显示当前会话状态
undo
撤销上一次操作
redo
重做上一次撤销的操作
save-state
将会话状态保存到磁盘
list
列出所有已保存的会话

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.json

Or with JSON output for programmatic use

或使用JSON格式输出供程序调用

cli-anything-drawio --json project new -o myproject.json
undefined
cli-anything-drawio --json project new -o myproject.json
undefined

Interactive REPL Session

交互式REPL会话

Start an interactive session with undo/redo support.
bash
cli-anything-drawio
启动支持撤销/重做功能的交互式会话。
bash
cli-anything-drawio

Enter commands interactively

交互式输入命令

Use 'help' to see available commands

使用'help'查看可用命令

Use 'undo' and 'redo' for history navigation

使用'undo'和'redo'导航操作历史

undefined
undefined

Export 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 --overwrite

State 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 (
    --json
    flag): Structured JSON for agent consumption
bash
undefined
所有命令支持两种输出模式:
  • 人类可读格式(默认):表格、彩色文本、格式化内容
  • 机器可读格式
    --json
    参数):结构化JSON,供Agent调用
bash
undefined

Human 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
undefined
cli-anything-drawio --json project info -p project.json
undefined

For AI Agents

面向AI Agent的使用说明

When using this CLI programmatically:
  1. Always use
    --json
    flag
    for parseable output
  2. Check return codes - 0 for success, non-zero for errors
  3. Parse stderr for error messages on failure
  4. Use absolute paths for all file operations
  5. Verify outputs exist after export operations
当以编程方式使用本CLI时:
  1. 始终使用
    --json
    参数
    以获得可解析的输出
  2. 检查返回码 - 0表示成功,非0表示错误
  3. 解析stderr以获取失败时的错误信息
  4. 所有文件操作使用绝对路径
  5. 导出操作后验证输出文件是否存在

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