Implementation:0xsline OpenChatCut CLI Output
Appearance
| Knowledge Sources | |
|---|---|
| Domains | CLI, Formatting |
| Last Updated | 2026-10-22 14:00 GMT |
Overview
Output formatting utilities for the CLI that separate stdout (data) from stderr (diagnostics) for clean piping, with table rendering and JSON pretty-printing.
Description
The CLI Output module separates stdout (data) from stderr (diagnostics) so piping `occ --json` is clean. Handles EPIPE gracefully for piped commands. Provides table rendering, JSON pretty-printing, timestamp formatting (ISO), and duration formatting (frames→human-readable seconds/minutes).
Usage
- All CLI output: Every CLI command's output flows through these utilities.
Code Reference
Source Location
- Repository: OpenChatCut
- File: cli/output.ts
- Lines: 1-53
Signature
export function writeStdout(text: string): void;
export function writeStderr(text: string): void;
export function printJson(value: unknown): void;
export function renderTable(headers: string[], rows: string[][]): string;
export function formatTimestamp(ms: number): string;
export function formatDuration(frames: number, fps: number): string;
Import
import { writeStdout, writeStderr, printJson, renderTable, formatDuration } from './output.ts';
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| text | string | Yes | Text to write (for writeStdout/writeStderr) |
| value | unknown | Yes | Value to JSON-pretty-print (for printJson) |
| frames | number | Yes | Frame count (for formatDuration) |
Outputs
| Name | Type | Description |
|---|---|---|
| writeStdout() returns | void | Writes to stdout (data) |
| writeStderr() returns | void | Writes to stderr (diagnostics) |
| renderTable() returns | string | Formatted ASCII table |
Usage Examples
Outputting Data
import { writeStdout, printJson, renderTable } from './output.ts';
// JSON output to stdout
printJson({ name: 'project1', clips: 5 });
// Table output
writeStdout(renderTable(['ID', 'Name'], [['1', 'Intro'], ['2', 'Outro']]));
Related Pages
Requires Environment
Page Connections
Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment