Skip to content

command open

zmworm edited this page Mar 31, 2026 · 23 revisions

open / close

Start and stop a resident background process for faster multi-command workflows.

Synopsis

officecli open <file>
officecli close <file>

Description

open

Starts a background resident process that keeps the document loaded in memory. All subsequent commands targeting this file communicate with the resident via named pipes, avoiding repeated file I/O. This dramatically improves performance for multi-step workflows.

If a resident process is already running for the file, the command returns immediately without starting a duplicate.

close

Stops the resident process for the specified file, saving any pending changes. After closing, commands revert to direct file access mode.

Arguments

Name Type Required Default Description
file FileInfo Yes - Office document path (.docx, .xlsx, .pptx)

Options

Name Type Required Default Description
--json bool No false Output result as JSON envelope

Resident Mode Details

Named Pipe Communication

Each resident process creates two named pipes:

  • Main pipe: Handles command execution (serialized with a semaphore lock)
  • Ping pipe: Always responsive for connection checks and shutdown signals

Idle Timeout

The resident process automatically shuts down after 12 minutes of inactivity. The timer resets on every command.

Command Serialization

Commands are executed sequentially. Only one command runs at a time, ensuring data integrity.

Automatic Fallback

All commands (view, get, set, add, etc.) automatically detect whether a resident is running. If a resident is available, the command routes through it. Otherwise, the command falls back to direct file access. This means you can use the same command syntax regardless of mode.

Examples

# Start resident process
officecli open report.docx

# Run multiple commands (automatically uses resident)
officecli view report.docx text
officecli set report.docx /body/p[1] --prop bold=true
officecli add report.docx /body --type paragraph --prop text="New paragraph"
officecli set report.docx /body/p[2] --prop style=Heading1

# Save and close
officecli close report.docx
# Multi-step Excel workflow
officecli open data.xlsx
officecli set data.xlsx /Sheet1/A1 --prop value="Header" --prop bold=true
officecli set data.xlsx /Sheet1/A2 --prop value=100
officecli set data.xlsx /Sheet1/A3 --prop formula="=SUM(A2:A2)"
officecli close data.xlsx

Notes

  • The open command waits up to 5 seconds for the resident to become responsive.
  • You cannot use create on a file that has an active resident process.
  • If the resident crashes or is killed, subsequent commands automatically fall back to direct mode.

See Also


Based on OfficeCLI v1.0.28

Clone this wiki locally