Partials

Commands for managing partials in the Knock CLI.

#

Partial commands enable you to manage partials in your Knock account from the CLI.

Partial file structure

#

When partials are pulled from Knock, they are stored in directories named by their partial key. Each partial directory contains a partial.json file that describes the partial's properties, and a content file based on the partial's type (HTML, markdown, plaintext, or JSON).

The content file name depends on the partial's type:

  • HTML partials: content.html
  • Markdown partials: content.md
  • Plaintext partials: content.txt
  • JSON partials: content.json

If you're migrating your local partial files into Knock, you can arrange them using the example file structure above and then push them into Knock with a single command using knock partial push --all.

knock partial list [flags]

#

List all partials in the environment. Use an --environment flag to specify the target environment; if omitted, the Knock CLI defaults to the development environment.

Flags

--environmentstring

The environment to use. Defaults to development.

--hide-uncommitted-changesboolean

Should any uncommitted changes be hidden? Defaults to false.

--limitnumber

The total number to fetch per page.

--afterstring

Fetches all entries after this cursor.

--beforestring

Fetches all entries before this cursor.

--jsonstring

Format output as json.

knock partial new [flags]

#

Create a new partial with a minimal configuration.

The command will create a new partial directory in your local file system. By default, this will be in the partials resource directory set by your knock.json file, or the current working directory if not configured.

Flags

--keystring

The key for the partial. If not provided, will be prompted or inferred from the partial directory name.

--namestring

The name for the partial. If not provided, will be generated from the key.

--typestring

The type of partial to create. One of: html, markdown, text, json.

--environmentstring

The environment to use. Defaults to development.

--branchstring

The branch to use. Defaults to the main branch.

--pushboolean

Push the partial to Knock after creating it locally. Defaults to false.

--forceboolean

Overwrites an existing partial directory without prompting for confirmation. Defaults to false.

knock partial get <partial_key> [flags]

#

You can show more details about a given partial with the partial get command, followed by the target partial key.

Use an --environment flag to specify the target environment; if omitted, the Knock CLI defaults to the development environment.

Flags

--environmentstring

The environment to use. Defaults to development.

--hide-uncommitted-changesboolean

Should any uncommitted changes be hidden? Defaults to false.

--jsonstring

Format output as json.

knock partial pull <partial_key> [flags]

#

You can pull and download partial files from Knock to a local file system with the partial pull command. Knock CLI will create a new partial directory or update the existing partial directory in the local file system.

By default this command will resolve to the partial resource directory via your knock.json file. When not set, will use the current working directory as the default. In the case of the --all flag, the target directory path will be resolved via your knock.json file or the --partials-dir flag.

Note: if pulling the target partial for the first time (or all partials), Knock CLI will ask to confirm before writing to the local file system.

See the Partial file structure section for details on how partial files are organized.

Flags

--environmentstring

The environment to use. Defaults to development.

--allboolean

Whether to pull all partials from the specified environment into the target directory path set by --partials-dir. Defaults to false.

Note: all contents in the target directory will be erased and replaced with all partials from the specified environment.

--partials-dirdirectory

Specifies which target directory path to pull all partials into. Only available to be used with --all, and defaults to the current working directory.

--hide-uncommitted-changesboolean

Should any uncommitted changes be hidden? Defaults to false.

--forceboolean

Removes the confirmation prompt. Defaults to false.

knock partial push <partial_key> [flags]

#

You can push and upload a partial directory to Knock with the partial push command. Knock will update an existing partial by the matching partial key, or create a new partial if it does not exist yet.

By default this command will resolve to the partial resource directory via your knock.json file. When not set, will use the current working directory as the default. In the case of the --all flag, the target directory path will be resolved via your knock.json file or the --partials-dir flag.

Note:

  • The partial push command only pushes partials into the development environment.
  • You must be directly above the target partial directory when running the partial push command, so the CLI can locate the partial.json file.
  • You can also pass in the --commit flag (with an optional --commit-message flag) to commit the upserted changes immediately.

Flags

--commitboolean

Push and commit at the same time. Defaults to false.

-m, --commit-messagestring

The commit message to pass when using the --commit flag.

--allboolean

Whether to push all partial files to the target environment. Defaults to false.

--partials-dirdirectory

Specifies the target directory path to find and push all partials from. Only available to be used with --all, and defaults to the current working directory.

knock partial validate <partial_key> [flags]

#

Validates one or more partial files. Useful for checking if the file is valid before running the partial push method.

Can only be validated against the development environment.

Flags

--allboolean

Whether to validate all partial files. Defaults to false.

--partials-dirdirectory

Specifies the target directory path to find and validate all partial files from. Only available to be used with --all, and defaults to the current working directory.

New chat