Skip to content

CLI: Content types

Commands to create, change, and delete content types. Common flags that you can add to any command (--host, --json, and others) are in the CLI command reference.

The schema format (--schema) is in Field types and value formats. To change many content types at once, schema files let you check the changes more quickly.

Command Description
hakocms-cli content-types create Create a content type
hakocms-cli content-types delete Delete a content type, together with its entries
hakocms-cli content-types get Get a content type
hakocms-cli content-types list List content types
hakocms-cli content-types schema set Replace a content type’s schema
hakocms-cli content-types schema versions Schema change history
hakocms-cli content-types update Change a content type’s name and content type ID

Create a content type.

ターミナルウィンドウ
hakocms-cli content-types create [OPTIONS]
Flag or argument Description
-s, --space <SLUG> Space. If omitted: HAKOCMS_SPACE, hakocms-cli.toml, then the one set with spaces use, in that order
--endpoint <TEXT> Endpoint (the content type ID, the name used in Content API paths, such as blog-posts)
--kind <TEXT> The kind of content type. A collection (collection) holds many entries; a single (single) holds only one entry. Allowed values: collection, single
--name <TEXT> Display name
--schema <JSON> Schema ({"fields": [...]}). You can see the current form with content-types get. Use @file to read from a file, - to read from standard input
--data <JSON> The whole body (JSON). Use @file to read from a file, - to read from standard input. Other flags are applied on top of it

Delete a content type, together with its entries.

Deletes a content type and all of its entries.

It cannot be deleted while other content types reference it.

ターミナルウィンドウ
hakocms-cli content-types delete [OPTIONS] <ENDPOINT>
Flag or argument Description
-s, --space <SLUG> Space. If omitted: HAKOCMS_SPACE, hakocms-cli.toml, then the one set with spaces use, in that order
<ENDPOINT> The content type’s endpoint (such as blog-posts)
--confirm <NAME> To confirm, write the target’s name (when not running in a terminal)

Get a content type.

ターミナルウィンドウ
hakocms-cli content-types get [OPTIONS] <ENDPOINT>
Flag or argument Description
-s, --space <SLUG> Space. If omitted: HAKOCMS_SPACE, hakocms-cli.toml, then the one set with spaces use, in that order
<ENDPOINT> The content type’s endpoint (such as blog-posts)

List content types.

ターミナルウィンドウ
hakocms-cli content-types list [OPTIONS]
Flag or argument Description
-s, --space <SLUG> Space. If omitted: HAKOCMS_SPACE, hakocms-cli.toml, then the one set with spaces use, in that order

Replace a content type’s schema.

ターミナルウィンドウ
hakocms-cli content-types schema set [OPTIONS] --type <ID>
Flag or argument Description
-s, --space <SLUG> Space. If omitted: HAKOCMS_SPACE, hakocms-cli.toml, then the one set with spaces use, in that order
-t, --type <ID> Content type (required)
--allow-violations[=true|false] When current entries violate the new schema, apply it anyway, knowingly
--schema <JSON> Schema ({"fields": [...]}). You can see the current form with content-types get. Use @file to read from a file, - to read from standard input
--schema-version <N> The version when you started editing. If someone has updated it since, returns 409
--data <JSON> The whole body (JSON). Use @file to read from a file, - to read from standard input. Other flags are applied on top of it

Schema change history.

ターミナルウィンドウ
hakocms-cli content-types schema versions [OPTIONS] --type <ID>
Flag or argument Description
-s, --space <SLUG> Space. If omitted: HAKOCMS_SPACE, hakocms-cli.toml, then the one set with spaces use, in that order
-t, --type <ID> Content type (required)

Change a content type’s name and content type ID.

Changes a content type’s name and endpoint.

If you change the endpoint, the Content API path changes too.

ターミナルウィンドウ
hakocms-cli content-types update [OPTIONS] <ENDPOINT>
Flag or argument Description
-s, --space <SLUG> Space. If omitted: HAKOCMS_SPACE, hakocms-cli.toml, then the one set with spaces use, in that order
<ENDPOINT> The content type’s endpoint (such as blog-posts)
--endpoint <TEXT> Endpoint (content type ID). If you change it, the Content API path changes too
--name <TEXT> Display name
--data <JSON> The whole body (JSON). Use @file to read from a file, - to read from standard input. Other flags are applied on top of it