SaasKit. Task. Helpers
(saas_kit v3.0.0)
Copy Markdown
Shared helpers for SaaS Kit Mix tasks.
Centralizes the human/JSON output split. Every read-only task parses
--json via parse_opts/2, flips into JSON mode with enter_json_mode/1,
and emits its final payload via emit/3 or fail!/4.
JSON documents always include a stable schema_version and ok flag so
agents can rely on the shape. Stable error codes used across tasks:
not_configured—boilerplate_tokenmissing from configapi_unreachable— API call failed (timeout, 5xx, network)feature_not_found— requested feature slug does not exist
Summary
Functions
Emits the final result.
When --json is set, silence Mix.shell().info/1 so stdout stays pure JSON.
Returns opts unchanged for pipelining.
Emits a structured failure and halts with exit_code.
Prints human-readable text, but only when not in --json mode.
Parses task args with --json layered on top of task-specific switches.
Current JSON schema version. Exposed for tests and docs.
Functions
Emits the final result.
In --json mode: merges schema_version and ok: true into the payload
and prints it as one JSON line to stdout.
Otherwise: invokes human_fn with the raw payload to pretty-print.
When --json is set, silence Mix.shell().info/1 so stdout stays pure JSON.
Returns opts unchanged for pipelining.
Emits a structured failure and halts with exit_code.
In --json mode: {"schema_version":1,"ok":false,"error":{"code":...,"message":...}}
Otherwise: Mix.shell().error(message).
Prints human-readable text, but only when not in --json mode.
Parses task args with --json layered on top of task-specific switches.
Current JSON schema version. Exposed for tests and docs.