WordPress / WordPress/create-block-theme

Feature: Add wp cbt save CLI command

Open
#830 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement wp-cli
Dominant language
JavaScript
Stars
417
Forks
66
PR merge metrics
No merged PRs in 30d

Description

Part of #828 (which fulfills #688). Depends on the CBT_Theme_Save service refactor tracked in #828.

Goal

Expose the CBT_Theme_Save service as a WP-CLI subcommand so developers can persist Editor changes to disk from the terminal.

Scope

New file: includes/cli/class-cbt-cli-command.php

New class: CBT_CLI_Command extending WP_CLI_Command, with a save method.

Registration (in includes/class-create-block-theme.php):

if ( defined( 'WP_CLI' ) && WP_CLI ) {
    require_once plugin_dir_path( __DIR__ ) . 'includes/cli/class-cbt-cli-command.php';
    WP_CLI::add_command( 'cbt', 'CBT_CLI_Command' );
}

CLI surface

wp cbt save [--fonts] [--templates] [--styles] [--patterns]
            [--all] [--only-modified-templates] [--dry-run]
  • Flags are kebab-case publicly; the command translates internally to the saveFonts / saveTemplates / etc. keys the service expects
  • --all is a convenience for "save everything"
  • --only-modified-templates maps to processOnlySavedTemplates
  • --dry-run reports what would change without writing

Required behavior

  • Guard with wp_is_block_theme()WP_CLI::error() if not, mirroring the plugin UI gate documented in AGENTS.md
  • WP_CLI::error() if no save flag is passed (no silent no-op success)
  • All user-facing strings i18n'd via __( ..., 'create-block-theme' )
  • PHPDoc with shortdesc, full ## OPTIONS, and at least two ## EXAMPLES
  • Translate WP_Error from the service into WP_CLI::error()

Tests

PHPUnit tests against the command class (the service itself is covered in its own issue):

  • Flag normalization (kebab-case → service options)
  • Guard fires on non-block themes
  • Empty invocation produces an error

Out of scope

  • wp cbt export — separate issue tracked in #828
  • Behat features — not in the plugin's infrastructure today
  • Any other CBT operation as a CLI command

Acceptance

  • Manual smoke test: install plugin in a Studio site, run each flag combination against a block theme
  • wp help cbt save displays the documented options and examples
  • lint:php, test:php, test:unit all green

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with AGENTS.md, includes/class-create-block-theme.php, and the CBT_Theme_Save service refactor in #828; then add PHPUnit coverage for flag normalization and the non-block-theme and empty-invocation guards in the new command class. Done means the command is registered, its help shows the options and examples, manual flag combinations work on a block theme, and lint:php, test:php, and test:unit pass.

Written by the indexing model from the issue text.

Assessment

Tech stack
php, wordpress
Domain
cli
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
70/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.