--format

Select output format for non-interactive commands. One of `table` (default), `compact`, `json`.

Category: global-flags

Syntax

--format table|compact|json

Description

## Overview `--format` controls how the CLI renders result sets for non-interactive commands (`query`, `run`, and piped stdin). The three valid values are validated at argument-parse time by clap's `value_parser`, so a misspelled format fails before any network call. The default is `table`, which is suitable for human reading in a terminal. `compact` is denser and better for long result sets or narrow terminals. `json` is designed for machine consumption and tool pipelines. ## Behavior - `table`: Unicode-bordered grid with column headers, type-aware right-alignment for numerics, and truncation markers for very long cells. - `compact`: borderless rows with tab-separated cells. Preserves header row but omits column separators and padding. - `json`: single JSON object per result set, shape `{ columns: [{name, type}], rows: [[...]], rowCount: N, executionTimeMs: M }`. For `run`, each statement emits one JSON object; consumers should split on newline. - Applies uniformly across the non-interactive surfaces. The REPL and interactive shell ignore `--format` because they have their own renderers. - Invalid values (anything other than `table`, `compact`, `json`) fail at argument parsing with a clap error message listing the accepted values. ## Compatibility - Progress lines from `run` and the authentication banner go to stderr and are not affected by `--format`. Redirecting stdout to a file therefore captures only result data. - For statements that do not produce a result set (DML, DDL), `--format` applies to the `OK` response shape. In `json` mode the CLI emits `{ ok: true, message, executionTimeMs }` instead of an empty table.

Examples

# JSON for programmatic consumption
delta-forge-cli --format json query SELECT 1
# Compact rows for terminal scrolling
delta-forge-cli --format compact query SHOW TABLES
# Pipe JSON into jq to extract a field
delta-forge-cli --format json query SELECT * FROM orders LIMIT 5 | jq '.rows'
# Full Unicode table (default)
delta-forge-cli query 'SELECT id, status FROM orders LIMIT 5'
# JSON output from a batch script, results on stdout, progress on stderr
delta-forge-cli --format json run report.sql >results.ndjson
# Scalar extraction via jq
delta-forge-cli --format json query 'SELECT count(*) FROM sales.orders' | jq -r '.rows[0][0]'

Pitfalls

See Also

Open in interactive docs →   DeltaForge home →