CLI output and exit codes
The output formats and the exit codes of hakocms-cli. This page also collects the rules for using it from scripts and CI.
Output formats
Section titled “Output formats”| Option | List | Single item | Use when |
|---|---|---|---|
| None (terminal) | Table with headers | field: value lines |
A person reads it |
| None (pipe, file) | Tab-separated lines without headers | field: value lines |
Reading with cut or awk |
--json |
JSON array (formatted) | JSON object | Passing to other tools |
--jq <expression> |
Result of the expression | Result of the expression | Extracting only the values you need |
An example of a list printed to a terminal:
ID STATUS UPDATED AT CREATED ATpgxjuopeye1p published 2026-10-23T04:18:29.693Z 2026-10-23T04:18:29.693Ziazte4ghzm55 draft 2026-10-23T04:18:29.640Z 2026-10-23T04:18:29.640ZWhen passed to a pipe, there are no headers, and the columns are separated by tabs.
pgxjuopeye1p published 2026-10-23T04:18:29.693Z 2026-10-23T04:18:29.693Ziazte4ghzm55 draft 2026-10-23T04:18:29.640Z 2026-10-23T04:18:29.640Z- If the environment variable
NO_COLORis set, no color is used - Dates and times are output in RFC 3339 in UTC (
2026-10-23T04:18:29.693Z)
JSON (--json)
Section titled “JSON (--json)”Outputs the Admin API response as it is. The meaning of each item is the same as in the Admin API reference.
- A list is output as the array of contents, without the page wrapper (
totalCountand so on). It has the same shape when you go through all pages with--all - New items that
hakocms-clidoes not know about are also output as they are
jq expressions (--jq)
Section titled “jq expressions (--jq)”Filters JSON with a jq expression. The expression is applied to the JSON even without --json. You do not need to install jq separately.
| Result of the expression | Output |
|---|---|
| String | As is, on one line, without quotes |
Number, boolean, null |
As JSON, on one line |
| Object, array | As formatted JSON, on several lines |
Several results (.[]) |
Each result in turn, in the formats above |
hakocms-cli entries list -t posts --jq '.[].id' # One ID per linehakocms-cli entries list -t posts --all --jq 'length' # Counthakocms-cli entries list -t posts --jq '.[] | {id, status} | tojson' # One JSON object per lineStandard output and standard error
Section titled “Standard output and standard error”| What is output | Where |
|---|---|
| Results (table, JSON, result of the jq expression) | Standard output |
Progress (uploaded 1/2: …, apply …: queued), warnings, errors |
Standard error |
With --json or --jq, errors are output to standard error as JSON.
{"error":{"status":404,"message":"not found"}}status is the HTTP status from the Admin API. The meaning of each reason is in the Errors.
List sizes
Section titled “List sizes”| Flag | Contents |
|---|---|
| (none) | 30 items |
--limit <n> |
n items |
--all |
Everything, going through all pages |
Some lists, such as exports, return up to 20 items, newest first.
How confirmations are asked
Section titled “How confirmations are asked”Before an operation that cannot be undone, such as a deletion, the CLI asks whether to continue.
| Weight | Example | In a terminal | Outside a terminal (pipe, CI) |
|---|---|---|---|
| Light | Saving and publishing entries | Does not ask | Does not ask |
| Medium | Deleting entries, media, or webhooks; revoking API keys; applying a schema | Asks with [y/N] |
Requires --force |
| Heavy | Deleting spaces, content types, or users; anonymizing users | Makes you type the target’s name (slug, content type ID, or user ID) | Requires --confirm <name> (--force is not enough) |
Confirmation messages include the destination name and the space.
-
With
--no-input, the CLI asks nothing. If it needs to ask, it ends with an error -
Outside a terminal, without
--forceor--confirm, the CLI shows the following and ends without doing anythingerror: `entries delete pgxjuopeye1p` needs --force when it cannot ask (not a terminal, or --no-input)
Wait for jobs (--wait)
Section titled “Wait for jobs (--wait)”Exports, imports, and schema applies run as jobs inside Hako CMS. With --wait, the CLI checks every 2 seconds until the job finishes, then outputs the result.
export k4uexuzi2q9f: queuedexport k4uexuzi2q9f: succeededIf the job fails, the CLI ends with exit code 1.
Exit codes
Section titled “Exit codes”| Code | Meaning | Example |
|---|---|---|
| 0 | Success | |
| 1 | Error | API error (404, 400, and so on), network failure, answering “no” to a confirmation, job failure |
| 2 | Usage error | Misspelled flag, missing required argument, unreadable JSON, unknown destination name |
| 4 | Login required | No destination is set; the token is missing, expired, or revoked |
In scripts, you can branch on the exit code.
hakocms-cli entries get <entry ID> -t posts --json > entry.jsoncase $? in 0) echo "取り出しました" ;; 4) echo "ログインし直してください" >&2; exit 1 ;; *) echo "取り出せませんでした" >&2; exit 1 ;;esacVersion
Section titled “Version”hakocms-cli versionhakocms-cli 0.1.8 (Admin API 1)This shows the version of hakocms-cli and the major version of the Admin API it uses. If the major version of the Hako CMS Admin API differs, every command shows a warning. In that case, update hakocms-cli (Install the CLI).