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:

OptionTypeMeaning
--jsonswitchMachine-readable output on stdout, on every command. Errors: {"error":{"code","message","fix"},"exitCode"}.
--dry-runswitchChange nothing: print what would be sent (or the preview, where the API has one).
--yesswitchDo not ask before a change (-y). Required for a change when there is no terminal.
--waitswitchAfter a change that needs approval: wait for the host’s decision (exit 0 or 5).
--apiurlAPI address (default: the public one).
--langstringLanguage of the everyday commands. (en, hu)
--no-colorswitchPlain text. NO_COLOR=1 does the same.
--helpswitchHelp for a command (-h).
--versionswitchPrint the version (-v).

An option a command does not have is refused before anything is sent, with the command's own options (exit 2):

Command
hostemi units base-price u1 --amount 120 --json
Output (recorded, exit 2)
{
  "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"
}
Command
hostemi whoami --json
Output (recorded, exit 3)
{
  "error": {
    "code": "NOT_SIGNED_IN",
    "message": "Not signed in.",
    "fix": "Run: hostemi login (or set HOSTEMI_TOKEN)."
  },
  "exitCode": 3,
  "details": null
}

Exit codes

CodeNameMeaning
0OKDone.
1ERRORThe command failed: API error, network, not found, plan. `error.code` under --json says which.
2USAGEWrong arguments, or a change that needs --yes because there is no terminal to ask in. Nothing changed.
3AUTHNot signed in, or the key was refused. For `login` without a terminal: the sign-in link is on stderr.
4NEEDS_APPROVALNothing changed: the host has to approve it in the app. The approval link is printed.
5DECLINEDThe host declined it, or it expired (after --wait, or when applying such a change). Nothing changed.
6HOST_ONLYOnly the host can do this, in the app. The link is printed.

Environment variables

VariableMeaning
HOSTEMI_TOKENAPI key; wins over the stored one and is never written to disk
HOSTEMI_API_URLAPI address (default https://api.hostemi.com)
HOSTEMI_APP_URLWhere approval links point (default https://hostemi.com)
HOSTEMI_MCP_URLMCP server address (default https://mcp.hostemi.com/mcp)
HOSTEMI_NO_UPDATE_CHECKSet to 1 to never look for a newer version
NO_COLORSet 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 group

This is what the command reference is generated from.

Something missing from this page? Write to [email protected], or use the form on the Help page.