cli-anything-libreoffice

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

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

Show 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
undefined
cli-anything-libreoffice --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-libreoffice
当不指定子命令调用时,CLI会进入交互式REPL会话:
bash
cli-anything-libreoffice

Enter commands interactively with tab-completion and history

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

undefined
undefined

Command Groups

命令组

Document

文档

Document management commands.
CommandDescription
new
Create a new document
open
Open an existing project file
save
Save the current document
info
Show document information
profiles
List available page profiles
json
Print raw project JSON
文档管理命令。
命令描述
new
创建新文档
open
打开现有项目文件
save
保存当前文档
info
显示文档信息
profiles
列出可用页面配置文件
json
打印原始项目JSON数据

Writer

Writer

Writer (word processor) commands.
CommandDescription
add-paragraph
Add a paragraph to the document
add-heading
Add a heading to the document
add-list
Add a list to the document
add-table
Add a table to the document
add-page-break
Add a page break
remove
Remove a content item by index
list
List all content items
set-text
Set the text of a content item
Writer(文字处理器)命令。
命令描述
add-paragraph
向文档添加段落
add-heading
向文档添加标题
add-list
向文档添加列表
add-table
向文档添加表格
add-page-break
添加分页符
remove
根据索引删除内容项
list
列出所有内容项
set-text
设置内容项的文本

Calc

Calc

Calc (spreadsheet) commands.
CommandDescription
add-sheet
Add a new sheet
remove-sheet
Remove a sheet by index
rename-sheet
Rename a sheet
set-cell
Set a cell value
get-cell
Get a cell value
list-sheets
List all sheets
Calc(电子表格)命令。
命令描述
add-sheet
添加新工作表
remove-sheet
根据索引删除工作表
rename-sheet
重命名工作表
set-cell
设置单元格值
get-cell
获取单元格值
list-sheets
列出所有工作表

Impress

Impress

Impress (presentation) commands.
CommandDescription
add-slide
Add a slide to the presentation
remove-slide
Remove a slide by index
set-content
Update a slide's title and/or content
list-slides
List all slides
add-element
Add an element to a slide
Impress(演示文稿)命令。
命令描述
add-slide
向演示文稿添加幻灯片
remove-slide
根据索引删除幻灯片
set-content
更新幻灯片的标题和/或内容
list-slides
列出所有幻灯片
add-element
向幻灯片添加元素

Style Group

样式组

Style management commands.
CommandDescription
create
Create a new style
modify
Modify an existing style
list
List all styles
apply
Apply a style to a content item (Writer only)
remove
Remove a style
样式管理命令。
命令描述
create
创建新样式
modify
修改现有样式
list
列出所有样式
apply
为内容项应用样式(仅Writer可用)
remove
删除样式

Export Group

导出组

Export/render commands.
CommandDescription
presets
List export presets
preset-info
Show preset details
render
Export the document to a file
导出/渲染命令。
命令描述
presets
列出导出预设
preset-info
显示预设详情
render
将文档导出为文件

Session

会话

Session management commands.
CommandDescription
status
Show session status
undo
Undo the last operation
redo
Redo the last undone operation
history
Show undo history
会话管理命令。
命令描述
status
显示会话状态
undo
撤销上一次操作
redo
重做上一次撤销的操作
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.json

Or with JSON output for programmatic use

或以JSON格式输出供程序化使用

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

Interactive REPL Session

交互式REPL会话

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

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-libreoffice --project myproject.json export render output.pdf --overwrite
将项目导出为最终输出格式。
bash
cli-anything-libreoffice --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-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
undefined
cli-anything-libreoffice --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表示成功,非零表示错误
  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