CLI
The blamejs command, as a function. The shipped binary reads process.argv and calls it, so everything the command does is reachable from a script, a test or another tool without spawning a process.
It carries the operator tasks that need the framework's own keys and formats and so cannot be done with ordinary shell tools: migrations and seed data, API-key issuance and rotation, the audit chain's archive, export, verify and purge, backup inspection and live restore, the in-box mTLS CA, sealing and unsealing the vault, and the API-surface snapshot that gates a release.
Streams, environment and working directory are parameters rather than globals, so a test drives the command and reads what it wrote without touching the process it runs in.
b.cli.main(argv, opts?) #
{
stdout: object, // writable stream; default process.stdout
stderr: object, // writable stream; default process.stderr
env: object, // environment; default process.env
cwd: string, // working directory; default process.cwd()
}
Run one command and resolve with its exit code. argv is the argument list without the node executable and script path, so ["migrate", "status"] is what blamejs migrate status passes.
It resolves rather than exiting, so a caller decides what to do with the code. Nothing here calls process.exit.
With no arguments it writes the top-level help and answers 0. --version answers the framework version. --help on a command, or help , writes that command's usage; each usage string is also exported, so a tool can render one without running anything.
stdout, stderr, env and cwd default to the process's own and are replaceable, which is how the command is tested: give it a writable stream and read back exactly what an operator would have seen.
var b = require("@blamejs/core");
var out = [];
var code = await b.cli.main(["--version"], {
stdout: { write: function (s) { out.push(s); } },
});
code; // → 0
out.join("").trim(); // → the framework version