Skip to content

What you can do with the CLI

hakocms-cli is a tool for working with Hako CMS from the command line. You can do everything you can do in the admin with commands: spaces, content types, entries, media, API keys, webhooks, members, and more.

ターミナルウィンドウ
hakocms-cli entries list --space blog --type posts
Situation Example
Repeat the same operation Retag 100 entries at once. Upload many images at once
Make changes from CI Apply a schema file kept in your site’s repository to a space with GitHub Actions
Bring a production space in line with a test space Review the diff of content types you built in a test space, then apply them to the production space
Move from another CMS Load exported JSON as entries with a script
Pull data out and inspect it Get entries as JSON and filter them with jq to check them

When you fix entries one at a time while looking at them, the admin is a better fit. You can check your work on screen, and you can preview it.

Admin ────┐
├─→ Admin API ─→ Hako CMS environment
CLI ──────┘
Your site ─→ Content API (API key)
  • hakocms-cli uses the same Admin API as the admin. So it can do everything the admin can do, and it cannot do what the admin cannot do
  • hakocms-cli logs in as you and runs with your permissions. Operations that your space role does not allow are refused, just as in the admin
  • The Content API is what shows entries on your site. The Content API uses API keys. They are separate from the access tokens that hakocms-cli uses to log in
Access token (CLI) API key (Content API)
Acts as You (same permissions as the person who created it) The space (permissions set on the key)
API used Admin API Content API
Prefix hako_pat_ hako_
How to create hakocms-cli auth login, or [アクセストークン](Access tokens) in the admin [API キー](API keys) in the admin, or hakocms-cli api-keys create

hakocms-cli is a single executable that runs on your computer or on a CI machine. It runs on Linux, macOS, and Windows. You do not need to install any other software.

When you log in, the access token goes into your OS credential store (such as the macOS Keychain). You can stay logged in to several environments and switch between them.

Operations you perform with hakocms-cli are recorded in the space’s operation record (the audit log), just like operations in the admin. The record of who performed them shows your name and that the operation used an access token (View the audit log).

Within the same major version, Hako CMS does not change the shape of the Admin API. It only adds to it. So an old hakocms-cli can still connect to a newer Hako CMS. To use newly added operations, update hakocms-cli. Install the CLI explains how to upgrade.