CLI
One binary, six commands. From a checkout bun run src/cli/index.ts is the same entry point and takes every command and flag below.
Commands
| command | does |
|---|---|
crust init <dir> | scaffold into an empty directory: plain HTML and CSS, no bundler |
crust init <dir> --react | the React + Vite scaffold |
crust init <dir> --next | the Next.js scaffold, static export only |
crust init <dir> --svelte | the Svelte + Vite scaffold |
crust init <dir> --vue | the Vue + Vite scaffold |
crust init <dir> --solid | the Solid + Vite scaffold: Solid 2, no SolidStart |
crust dev [file] | watch the backend, restart it on change, keep the frontend with its own dev server |
crust build [file] | compile the binary; on macOS assemble X.app in dist/ and ad-hoc sign it; --sign --notarize --dmg add the release stages |
crust package [--format <fmt>] | release artefacts for dmg, appimage or nsis; --format is repeatable and defaults to dmg |
crust doctor | one line per launch check; exit 1 if any check failed |
crust perf record --app <dir> | launch with the perf sink and write one sample per second to --out; see the performance guide |
crust perf diff <a> <b> | compare two records field by field; exit 1 when a metric regressed past --tolerance |
crust perf owns its argv and its own crust perf --help, so it is not one of the five cac commands — but it is the sixth thing the binary can do.
crust perf diff writes its failures — a bad --tolerance, an unreadable record, or a record with no frame block — to stderr with exit 1; the comparison table and its REGRESS rows stay on stdout. crust perf record detaches its trap and re-raises SIGINT, SIGTERM and SIGHUP, and a failed run removes its --out file, so a later diff cannot read the previous run's result as this run's.
crust sign, crust dmg and crust notarize are gone. Each now prints crust: unknown command "<verb>" and exits 1. Their work is done by stages of crust build, run in one invocation after the plain build in this order: build → ad-hoc sign → --sign → --notarize → --dmg. --sign replaces the ad-hoc signature with a Developer ID; --notarize submits the signed app, then staples and validates its ticket; --dmg builds the image from the already-stapled app. The disk image itself is not notarized — the app's ticket travels inside it.
init refuses a non-empty directory, naming the entries it found, rather than merging into it.
Flags
| flag | applies to | does |
|---|---|---|
--dir <path> | all | project directory, default the current directory |
--config <path> | all | config file, relative to --dir |
--entry <path> | all | backend entry, relative to --dir, default src/main.ts then main.ts |
--format <fmt> | package | dmg, appimage or nsis; repeat the flag for several |
--log-level <level> | dev | trace, debug, info, warn or error for this run; default info |
--sign | build | Developer ID sign the app, replacing the ad-hoc signature (needs CRUST_SIGNING_IDENTITY) |
--notarize | build | notarize and staple the signed app; implies --sign |
--dmg | build | build a disk image from the signed app (macOS) |
--react | init | copy the React + Vite template |
--next | init | copy the Next.js template |
--svelte | init | copy the Svelte + Vite template |
--vue | init | copy the Vue + Vite template |
--solid | init | copy the Vite + Solid 2 template |
--help, -h | all | print the usage text, exit 0 |
--version, -v | all | print the version, exit 0 |
The five init flags are different scaffolds; passing two is refused before anything is written, naming each flag with the scaffold it copies. Any of them outside init fails with crust: --svelte only applies to init. init takes the directory once — a positional and --dir together is init takes one directory — pass <dir> or --dir, not both. An unknown option, a second positional, or a flag missing its value prints crust: <reason> then run "crust --help" for usage, and exits 1. Any stage flag on a command other than build fails with --<flag> only applies to build, and --log-level outside dev with --log-level only applies to dev. A value --log-level does not recognise is refused by name — unknown log level "verbose" — expected trace, debug, info, warn or error — rather than quietly running at the default.
The stages refuse before any build work runs. --notarize without --sign is notarize requires --sign — an ad-hoc signature cannot be submitted; add --sign with CRUST_SIGNING_IDENTITY. --sign without the identity is sign requires CRUST_SIGNING_IDENTITY — set "Developer ID Application: Name (TEAMID)". Off macOS, --dmg and --sign refuse with --dmg has no disk image on <platform> — a disk image is macOS only and --sign needs codesign, which is macOS-only (this platform is <platform>). --notarize without a credential or Developer ID signature names which is missing.
Single-file mode
| command | does |
|---|---|
crust dev app.tsx | run that one file as the whole app, with no config |
crust build app.tsx | build from the file; dist/<basename>.app on macOS |
The config is built in memory: id crust.single.<slug>, name and window title from the basename, version 0.0.0, one window at 900×700. The page is bundled to <dir>/.crust/single in dev and <dir>/dist/single in a build. The backend is the framework itself — info and echo are registered, so invoke("info") proves the round trip — and every plugin is still reachable in the three-argument form. A file whose source contains export default is mounted as a React component, so react and react-dom must be installed beside it; any other file is loaded for its own side effects. A crust.config.ts beside the file is refused rather than guessed at.
crust dev
- With
dev.urlset,beforeDevCommandis started throughsh -c, then the runtime waits up to 30 s for a TCP connect on that port before opening a window. - Backend edits restart the runtime process. Under
dev.url, saves of.tsx,.jsx,.css,.scss,.sass,.less,.htmland image files do not, because the dev server owns them and a restart rotates the bridge token. .tsand.jsalways restart it, since the backend entry is one of them —crust doctorreports page-side.tsfiles as a note for exactly this reason.- Change watching skips
public,dist,node_modules,.next,outand.crust. - The runtime logs at
info: lifecycle and refusals reach the terminal, successful invokes do not.--log-level debugbrings the invokes back, andwarnsilences lifecycle while keeping refusals and errors.
crust doctor
Checks, in order: platform, bun, config, macos, shim, bridge, dev port, dev url, backend, dev watch, window, source (known-fatal traps, only in an app directory with a config), assets, templates, bundle, gatekeeper (only when a .app is in dist/), then the extensions block. Each line is [ok], [note] or [fail], and only fail is counted. The run ends all checks passed with exit 0, or N checks failed with exit 1.
The extensions block reports zig, rustc and clang as found with their version or missing, then one verdict per .zig, .rs or .c file under native/. A source file whose compiler is missing counts as a failure; a project with no native/ directory prints one line and adds nothing to the count.
dev port classifies the port dev.url names before dev url probes it: free, held by a process that answers the URL (a note), held by one that answers nothing (the strictPort failure and the only fail in that pair), or answering while nothing listens locally (a proxy, a note).
Environment
| variable | read by | does |
|---|---|---|
CRUST_SIGNING_IDENTITY | crust build --sign, --notarize | the Developer ID identity to sign with; absent, --sign fails naming the variable and prints the expected form |
CRUST_NOTARY_PROFILE | crust build --notarize | a notarytool store-credentials profile; wins over the one-shot route |
CRUST_NOTARY_APPLE_ID | crust build --notarize | the Apple ID for the one-shot credential route |
CRUST_NOTARY_PASSWORD | crust build --notarize | the app-specific password for that Apple ID |
CRUST_NOTARY_TEAM_ID | crust build --notarize | the team the Apple ID belongs to |
CRUST_DEV_FILE | crust/vite | the bridge handshake path, default devHandshakePath() in the OS temp dir |
CRUST_LOG | crust dev, every crust runtime | minimum log level: trace, debug, info, warn or error; beats logging.level, loses to --log-level |
CRUST_SHIM_AUDIT | darwin shim in crust dev / e2e harness | 1 adds ownership counters to the macOS C shim; a source checkout only — see below |
XDG_CACHE_HOME | compiled crust CLI | base for the private crust/framework/<version> cache, default ~/.cache; a tampered tree is refused by name |
CRUST_SHIM_AUDIT=1 is a framework switch, not an app setting. It adds -DCRUST_SHIM_AUDIT when the macOS shim is compiled, so each audited unit counts acquisitions and drops and the harness can assert a zero balance; requestShimAudit() is the programmatic form the in-repo harness uses. Both go through the same availability check, which turns the switch into a no-op when NODE_ENV is production or the shim/*.c sources are not on disk — the case in a compiled binary. Use it from a source checkout in crust dev or an e2e run; a shipped app cannot be audited this way.
An uncaught command failure prints crust <command>: <message> and exits 1. Nothing prints a stack trace and nothing exits 0 on a refusal.