cli-anything-libreoffice
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinesecli-anything-libreoffice
cli-anything-libreoffice
A stateful command-line interface for document editing, producing real ODF files (ZIP archives with XML). Designed for AI agents and power users who need to create and manipulate Writer, Calc, and Impress documents without a GUI or LibreOffice installation.
一款支持状态管理的文档编辑命令行界面,可生成真实的ODF文件(包含XML的ZIP归档文件)。专为AI Agent和高级用户设计,无需GUI或安装LibreOffice即可创建和处理Writer、Calc、Impress文档。
Installation
安装
This CLI is installed as part of the cli-anything-libreoffice package:
bash
pip install cli-anything-libreofficePrerequisites:
- Python 3.10+
- libreoffice must be installed on your system
此CLI作为cli-anything-libreoffice包的一部分进行安装:
bash
pip install cli-anything-libreoffice前提条件:
- Python 3.10+
- 系统中必须安装libreoffice
Usage
使用
Basic Commands
基础命令
bash
undefinedbash
undefinedShow help
显示帮助信息
cli-anything-libreoffice --help
cli-anything-libreoffice --help
Start interactive REPL mode
启动交互式REPL模式
cli-anything-libreoffice
cli-anything-libreoffice
Create a new project
创建新项目
cli-anything-libreoffice project new -o project.json
cli-anything-libreoffice project new -o project.json
Run with JSON output (for agent consumption)
以JSON格式输出(供Agent使用)
cli-anything-libreoffice --json project info -p project.json
undefinedcli-anything-libreoffice --json project info -p project.json
undefinedREPL Mode
REPL模式
When invoked without a subcommand, the CLI enters an interactive REPL session:
bash
cli-anything-libreoffice当不指定子命令调用时,CLI会进入交互式REPL会话:
bash
cli-anything-libreofficeEnter commands interactively with tab-completion and history
交互式输入命令,支持自动补全和历史记录
undefinedundefinedCommand Groups
命令组
Document
文档
Document management commands.
| Command | Description |
|---|---|
| Create a new document |
| Open an existing project file |
| Save the current document |
| Show document information |
| List available page profiles |
| Print raw project JSON |
文档管理命令。
| 命令 | 描述 |
|---|---|
| 创建新文档 |
| 打开现有项目文件 |
| 保存当前文档 |
| 显示文档信息 |
| 列出可用页面配置文件 |
| 打印原始项目JSON数据 |
Writer
Writer
Writer (word processor) commands.
| Command | Description |
|---|---|
| Add a paragraph to the document |
| Add a heading to the document |
| Add a list to the document |
| Add a table to the document |
| Add a page break |
| Remove a content item by index |
| List all content items |
| Set the text of a content item |
Writer(文字处理器)命令。
| 命令 | 描述 |
|---|---|
| 向文档添加段落 |
| 向文档添加标题 |
| 向文档添加列表 |
| 向文档添加表格 |
| 添加分页符 |
| 根据索引删除内容项 |
| 列出所有内容项 |
| 设置内容项的文本 |
Calc
Calc
Calc (spreadsheet) commands.
| Command | Description |
|---|---|
| Add a new sheet |
| Remove a sheet by index |
| Rename a sheet |
| Set a cell value |
| Get a cell value |
| List all sheets |
Calc(电子表格)命令。
| 命令 | 描述 |
|---|---|
| 添加新工作表 |
| 根据索引删除工作表 |
| 重命名工作表 |
| 设置单元格值 |
| 获取单元格值 |
| 列出所有工作表 |
Impress
Impress
Impress (presentation) commands.
| Command | Description |
|---|---|
| Add a slide to the presentation |
| Remove a slide by index |
| Update a slide's title and/or content |
| List all slides |
| Add an element to a slide |
Impress(演示文稿)命令。
| 命令 | 描述 |
|---|---|
| 向演示文稿添加幻灯片 |
| 根据索引删除幻灯片 |
| 更新幻灯片的标题和/或内容 |
| 列出所有幻灯片 |
| 向幻灯片添加元素 |
Style Group
样式组
Style management commands.
| Command | Description |
|---|---|
| Create a new style |
| Modify an existing style |
| List all styles |
| Apply a style to a content item (Writer only) |
| Remove a style |
样式管理命令。
| 命令 | 描述 |
|---|---|
| 创建新样式 |
| 修改现有样式 |
| 列出所有样式 |
| 为内容项应用样式(仅Writer可用) |
| 删除样式 |
Export Group
导出组
Export/render commands.
| Command | Description |
|---|---|
| List export presets |
| Show preset details |
| Export the document to a file |
导出/渲染命令。
| 命令 | 描述 |
|---|---|
| 列出导出预设 |
| 显示预设详情 |
| 将文档导出为文件 |
Session
会话
Session management commands.
| Command | Description |
|---|---|
| Show session status |
| Undo the last operation |
| Redo the last undone operation |
| Show undo history |
会话管理命令。
| 命令 | 描述 |
|---|---|
| 显示会话状态 |
| 撤销上一次操作 |
| 重做上一次撤销的操作 |
| 显示撤销历史 |
Examples
示例
Create a New Project
创建新项目
Create a new libreoffice project file.
bash
cli-anything-libreoffice project new -o myproject.json创建新的libreoffice项目文件。
bash
cli-anything-libreoffice project new -o myproject.jsonOr with JSON output for programmatic use
或以JSON格式输出供程序化使用
cli-anything-libreoffice --json project new -o myproject.json
undefinedcli-anything-libreoffice --json project new -o myproject.json
undefinedInteractive REPL Session
交互式REPL会话
Start an interactive session with undo/redo support.
bash
cli-anything-libreoffice启动支持撤销/重做功能的交互式会话。
bash
cli-anything-libreofficeEnter 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-libreoffice --project myproject.json export render output.pdf --overwrite将项目导出为最终输出格式。
bash
cli-anything-libreoffice --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-libreoffice project info -p project.json
cli-anything-libreoffice project info -p project.json
JSON output for agents
供Agent使用的JSON输出
cli-anything-libreoffice --json project info -p project.json
undefinedcli-anything-libreoffice --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表示成功,非零表示错误
- 解析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