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.
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
Usage
Basic Commands
bash
# Show help
cli-anything-libreoffice --help
# Start interactive REPL mode
cli-anything-libreoffice
# Create a new project
cli-anything-libreoffice project new -o project.json
# Run with JSON output (for agent consumption)
cli-anything-libreoffice --json project info -p project.json
REPL Mode
When invoked without a subcommand, the CLI enters an interactive REPL session:
bash
cli-anything-libreoffice
# Enter commands interactively with tab-completion and history
Command 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 |
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 |
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 |
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 |
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 |
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
# Or with JSON output for programmatic use
cli-anything-libreoffice --json project new -o myproject.json
Interactive REPL Session
Start an interactive session with undo/redo support.
bash
cli-anything-libreoffice
# Enter commands interactively
# Use 'help' to see available commands
# Use 'undo' and 'redo' for history navigation
Export Project
Export the project to a final output format.
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
Output Formats
All commands support dual output modes:
- Human-readable (default): Tables, colors, formatted text
- Machine-readable ( flag): Structured JSON for agent consumption
bash
# Human output
cli-anything-libreoffice project info -p project.json
# JSON output for agents
cli-anything-libreoffice --json project info -p project.json
For AI Agents
When using this CLI programmatically:
- Always use flag for parseable output
- 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
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
Version
1.0.0