Skip to main content

Module output

Module output 

Source
Expand description

Output rendering and exit codes.

Exit-code table — process status only; the JSON body carries the stable UPPER_SNAKE_CASE code under code:

CodeMeaning
0Success
1Generic error (IO, engine init, parse)
2Usage / invalid arguments (emitted by clap)
3Not found (entity / mem / resource missing)
4Hash mismatch (optimistic-lock violation)
5Validation error (schema, relation type, etc.)

In --json mode, errors emit the documented {code, message, details} envelope — same shape agents consume over MCP — to stdout, so the documented memstead <sub> … --json | jq -r .code recipe retrieves the typed code on the error path without a 2>&1 redirect (success responses already go to stdout; the structured error joins them there). The human-facing markdown error path (no --json) stays on stderr and begins memstead: ERROR [<CODE>]: <message> so consumers reading only the text channel recover the typed code with one regex.

Enums§

ErrorStream
Which standard stream a rendered CLI error is written to.
ExitKind
Exit-code kind for CLI errors.

Functions§

print_cli_error
Print a typed CLI error in the documented surface shape, routed per render_cli_error: the structured --json envelope to stdout, the human markdown form to stderr. The exit code (set by the caller from ExitKind) signals failure independently of the stream.
print_json
Print a serializable value as pretty JSON to stdout.
print_markdown
Print markdown (or JSON when requested) to stdout.
render_cli_error
Decide the target stream and serialized line for a CLI error. Pure — the routing decision is unit-testable without capturing process streams. Under --json the {code, message, details} envelope goes to stdout so the documented memstead <sub> … --json | jq -r .code recipe works on the error path (a stdout-only pipe); the human markdown form goes to stderr. code is the stable UPPER_SNAKE_CASE token (matching the wire envelope agents see over MCP); details carries the structured recovery payload under the details key.