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).
partials/ └── author-block/ ├── content.html └── partial.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
The environment to use. Defaults to development.
Should any uncommitted changes be hidden? Defaults to false.
The total number to fetch per page.
Fetches all entries after this cursor.
Fetches all entries before this cursor.
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
The key for the partial. If not provided, will be prompted or inferred from the partial directory name.
The name for the partial. If not provided, will be generated from the key.
The type of partial to create. One of: html, markdown, text, json.
The environment to use. Defaults to development.
The branch to use. Defaults to the main branch.
Push the partial to Knock after creating it locally. Defaults to false.
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
The environment to use. Defaults to development.
Should any uncommitted changes be hidden? Defaults to false.
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
The environment to use. Defaults to development.
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.
Specifies which target directory path to pull all partials into. Only available to be used with --all, and defaults to the current working directory.
Should any uncommitted changes be hidden? Defaults to false.
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 pushcommand only pushes partials into thedevelopmentenvironment. - You must be directly above the target partial directory when running the
partial pushcommand, so the CLI can locate thepartial.jsonfile. - You can also pass in the
--commitflag (with an optional--commit-messageflag) to commit the upserted changes immediately.
Flags
Push and commit at the same time. Defaults to false.
The commit message to pass when using the --commit flag.
Whether to push all partial files to the target environment. Defaults to false.
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
Whether to validate all partial files. Defaults to false.
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.