Wit

CLI reference

The complete command-line contract: five subcommands, every flag, exit codes, diagnostics, and environment variables. Source: packages/cli/src/*.ts.

Synopsis

wit parse <file>
wit check <file>
wit fmt <file> [-w|--write]
wit build <file> [-o out.html|out.md|out.pdf] [--format html|md|pdf] [--raw | --fragment]
                  [--sources wit.sources.json --allow-exec] [--env .env]
wit tour <file>
wit --version | --help

Global

Global flags
InvocationResultExit
wit --help or -husage text0
wit --version or -vprints 0.2.00
unknown commandhelp on stderr2

wit parse

Parse a file and print its AST as pretty JSON. No flags.

parse
OutcomeExit
prints AST JSON0
parse error — diagnostic on stderr1
missing file argument2

wit check

Parse and resolve — a fast validity check. No flags. Does not expand or render; catches resolve-stage errors only.

check
OutcomeExit
clean — prints ok and the path0
any stage error1
missing file argument2

wit fmt

Structural re-indent. Prints to stdout by default.

fmt
FlagMeaningDefault
-w or --writewrite in place; prints formatted or unchangedstdout
parse errornothing written; exit 1

Preserves prose exactly and leaves raw double-at bodies, scripts, record and data values, and form-fill bodies verbatim. Missing file argument → exit 2.

wit build

The full pipeline: parse → load → resolve → expand → render.

build flags
FlagArgumentMeaningDefault
-o or --outa pathoutput file; format inferred from extensionstdout
--formathtml or md or pdfexplicit format overriding inferencehtml
--fragmentnonebare wit-doc article onlyoff
--rawnonefull document with reset-only CSSoff
--sourcesa json fileexternal-data source confignone
--enva dotenv filemerged into the env source and child envnone
--allow-execnonepermit running configured source programsoff

Format inference

Output format from extension
ExtensionFormat
.html or .htmhtml
.md or .markdownmd
.pdfpdf
anything elseE_UNKNOWN_OUTPUT_FORMAT — exit 1

--raw versus --fragment

If both are given, --fragment wins: the HTML options return early on fragment before checking raw. --fragmentemits <article class="wit-doc"> only; --raw emits a full document with a reset-only base for author-supplied styling; the default is a self-contained styled document (a Word-like house style).

PDF specifics

Requires -o <file.pdf>

an error, exit 1

. Drives a headless system Chrome or Chromium (candidate list in the source, or a WIT_CHROME override — the override wins with no fallback). Injects a base href (the document directory) so relative assets resolve; runs with a 60-second timeout; writes a temporary HTML then unlinks it. No Chrome → a helpful error, exit 1. Success → prints the written path.

wit tour

An indented AST tree plus an AST-coverage report.

tour
FlagMeaning
--reportforce report mode even on a non-TTY
--no-reporttree only — for piping
defaultreport on a TTY

The footer reports AST kinds seen: X/Y against the 24 known kinds, plus the paramsSource variants and NodeDef shapes seen. Overridable by WIT_TOUR_REPORT=1 / WIT_TOUR_NO_REPORT=1. Unknown flag → exit 2. Checked output lives in tests/integration/feature-tour.tour.txt.

Cross-cutting

Exit codes
Exit codeMeaning
0success
1stage or IO error
2usage error
Environment variables
Env varEffect
WIT_CHROMEPDF browser override — no fallback
WIT_DEBUG_COMMENTS=1keep comments in the HTML render
WIT_TOUR_REPORT / WIT_TOUR_NO_REPORTforce tour report mode

All diagnostics use file:line:col: E_CODE: message. See the error catalogue.

See also

Config

· Errors · API · CLI guide.