DOC_INDEX
THEME
DOCS/Specification/Output & Exit Codes

Output & Exit Codes

Machine-readable run output (pretty, plain, json) with TTY auto-detect, and the documented exit-code contract for CI

orchstep run renders its progress in one of three modes, chosen with --output (it also auto-detects: a real terminal gets pretty, a pipe or CI gets plain).

ModeWhenWhat you get
prettydefault on a TTYthe interactive emoji / box-drawing output
plaindefault when piped / in CIclean line-oriented text, no emoji or boxes
jsonopt-ina single structured document, all streaming suppressed
orchstep run deploy                 # pretty on a terminal, plain when piped
orchstep run deploy --output plain  # force plain
orchstep run deploy --output json   # structured result

Plain

Workflow: deploy
Task: main
  Step: build
  $ make build
...build output...
  [ok] build
Result: success

JSON

--output json prints exactly one JSON document (nothing else on stdout), so you can pipe it straight into jq:

{
  "workflow": "deploy",
  "task": "main",
  "status": "success",
  "steps": [
    { "task": "main", "name": "build", "status": "ok", "output": "..." }
  ]
}
orchstep run deploy --output json | jq -r '.status'
orchstep run deploy --output json | jq '.steps[] | select(.status=="failed")'

Logs and structured output: --json-file

--output json is exclusive - it suppresses the logs so stdout is pure JSON. When you want both the human-readable logs and a machine-readable result (the common CI case), keep a normal output mode and write the structured result to a file:

orchstep run deploy --output plain --json-file result.json
# stdout: the full plain logs (visible in the CI run)
# result.json: the same RunResult document, for a later step / artifact

--json-file works with any --output mode (pretty, plain, or json) and is written even when the run fails, so a downstream step can always inspect what happened.

Exit codes

orchstep run follows a documented exit-code contract, so CI can branch on the kind of failure, not just pass/fail:

CodeMeaning
0success
1a task/step failed at execution time (also: bad flags / unknown command)
2usage error — e.g. no subcommand given in a non-TTY pipeline
3the workflow could not be loaded/parsed (unknown key, unmet required.orchstep, missing file)
4an assert step failed
orchstep run check
case $? in
  0) echo "ok" ;;
  4) echo "an assertion failed" ;;
  3) echo "the workflow itself is broken" ;;
  *) echo "a step failed" ;;
esac

This pairs with the engine-version (required.orchstep) and lockfile checks: those surface as exit 3 (load) so a misconfigured pipeline fails fast and distinctly from a genuine task failure.