# Output formats

Source: https://libtmux.org/en/csharp/latest/workspace/reference/output/

> Read JSON results, NDJSON events and diagnostics from the workspace command.

Every command accepts `--json` and `--ndjson`. JSON writes one document to
stdout. NDJSON writes one JSON record per line and takes precedence if both
flags are present. Machine output contains no terminal styling.

## Choose a stream

```console
$ tmux-workspace ls --json
```

The shape depends on the operation: listing and search describe workspace
records; conversion and import can return the translated document; loading
describes completed work and failures. Saving a document returns information
about that save. The file's YAML/JSON encoding is controlled separately by
`--workspace-format`.

Use [automation](https://libtmux.org/en/csharp/latest/workspace/guides/automation/) for a detached load and streamed
progress. Read stdout as results and stderr as diagnostics. Check the exit
status even when stdout contains valid data.

## Partial work and interrupted streams

Load results can contain completed inputs, created IDs and retained effects.
Treat a failed operation as partial until its result tells you what remains.
A creation event alone does not establish that the workspace finished.

An output failure or interruption can leave a final record unwritten or
incomplete. A consumer must handle EOF and parse errors. Preserve the exit
status and inspect the private server before retrying mutations.

## Child output and logging

Machine calls encode captured child text so it cannot be confused with result
records. The optional [inspection shell](https://libtmux.org/en/csharp/latest/workspace/cli/shell/) reports its child
status along with captured output. A nonzero editor status is propagated.

NDJSON can carry child-output records while a command is running. Read the
terminal result and child status after those records.

`load --log-file PATH` appends diagnostics to a separate file. `--log-level`
selects advisory detail. A later log-file failure reports a diagnostic and
preserves the operation's result; the log can end with an incomplete record.

## Human output

`--color auto|always|never` selects styling; nonempty `NO_COLOR` disables color.
Human progress uses the terminal. `--no-progress` disables drawing without
hiding errors. Redirected or machine output avoids the progress display.

[CLI source](https://github.com/libtmux/libtmux-dotnet/blob/f77fe776ba67a04abb20ddbbc26cf4a000d63b74/src/LibTmux.Workspace.Cli/README.md).
