Global options, output and exit codes
The options every command takes, JSON output, colour, environment variables and the exit codes.
Global options
Every command takes these:
| Option | Type | Meaning |
|---|---|---|
--json | switch | Machine-readable output on stdout, on every command. Errors: {"error":{"code","message","fix"},"exitCode"}. |
--dry-run | switch | Change nothing: print what would be sent (or the preview, where the API has one). |
--yes | switch | Do not ask before a change (-y). Required for a change when there is no terminal. |
--wait | switch | After a change that needs approval: wait for the host’s decision (exit 0 or 5). |
--api | url | API address (default: the public one). |
--lang | string | Language of the everyday commands. (en, hu) |
--no-color | switch | Plain text. NO_COLOR=1 does the same. |
--help | switch | Help for a command (-h). |
--version | switch | Print the version (-v). |
An option a command does not have is refused before anything is sent, with the command's own options (exit 2):
hostemi units base-price u1 --amount 120 --json{
"error": {
"code": "USAGE",
"message": "Unknown option --amount. Its options: --minor.\nUsage: hostemi units base-price <id> [price] [options]",
"fix": null
},
"exitCode": 2,
"details": null
}Output: tables and JSON
For a person the CLI prints short tables and sentences, in colour on a terminal. --json prints machine-readable JSON on stdout instead: for API commands the API's own answer, with approvalUrl and exitCode added when a change waits for the host. Errors, notices and "waiting" lines go to stderr, so a pipe gets only the data; under --json an error is one object on stdout.
Colour is off when the output is not a terminal, with --json, with --no-color, with NO_COLOR set, or with TERM=dumb.
Errors as JSON
With --json a failure is one object on stdout:
{
"error": {
"code": "string",
"message": "string",
"fix": "string|null"
},
"exitCode": "number",
"details": "object|null"
}hostemi whoami --json{
"error": {
"code": "NOT_SIGNED_IN",
"message": "Not signed in.",
"fix": "Run: hostemi login (or set HOSTEMI_TOKEN)."
},
"exitCode": 3,
"details": null
}Exit codes
| Code | Name | Meaning |
|---|---|---|
| 0 | OK | Done. |
| 1 | ERROR | The command failed: API error, network, not found, plan. `error.code` under --json says which. |
| 2 | USAGE | Wrong arguments, or a change that needs --yes because there is no terminal to ask in. Nothing changed. |
| 3 | AUTH | Not signed in, or the key was refused. For `login` without a terminal: the sign-in link is on stderr. |
| 4 | NEEDS_APPROVAL | Nothing changed: the host has to approve it in the app. The approval link is printed. |
| 5 | DECLINED | The host declined it, or it expired (after --wait, or when applying such a change). Nothing changed. |
| 6 | HOST_ONLY | Only the host can do this, in the app. The link is printed. |
Environment variables
| Variable | Meaning |
|---|---|
HOSTEMI_TOKEN | API key; wins over the stored one and is never written to disk |
HOSTEMI_API_URL | API address (default https://api.hostemi.com) |
HOSTEMI_APP_URL | Where approval links point (default https://hostemi.com) |
HOSTEMI_MCP_URL | MCP server address (default https://mcp.hostemi.com/mcp) |
HOSTEMI_NO_UPDATE_CHECK | Set to 1 to never look for a newer version |
NO_COLOR | Set to anything to turn colour off |
Never interactive without a terminal
Without a terminal on stdin and stdout the CLI never asks and never waits: a change needs --yes (otherwise exit 2, nothing changed), login prints its link and exits 3, and approvals are waited for only with --wait.
The command tree as data
hostemi help --json # every command, argument, option, mode and exit code
hostemi help bookings --json # one groupThis is what the command reference is generated from.