Skip to content

Feature: Add wp cbt save CLI command #830

@bph

Description

@bph

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

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestwp-clihandling wp-cli commands in this plugin

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions