Skip to content
This repository was archived by the owner on Dec 16, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions includes/class-command-base.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,10 @@ abstract protected function name(): string;
/**
* This class must be invocable.
*
* @param array $args An array of arguments might be provided.
* @param array $args Optional. Command arguments.
* @param array $assoc_args Optional. Associative array of command options.
*/
abstract public function __invoke( array $args = array() );
abstract public function __invoke( array $args = array(), array $assoc_args = array() );

/**
* Registers this command.
Expand Down
12 changes: 8 additions & 4 deletions includes/class-installer.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,21 +90,25 @@ private function update_file_string_replacements() {

/**
* Installs theme files.
*
* @param bool $force (Optional) Whether theme files will be overidden. If omitted, theme files will only be created if they do not exist. Defaults to false if not specified.
*/
public function install() {
$this->copy_theme_files();
public function install( bool $force = false ) {
$this->copy_theme_files( $force );
new All_Blocks_Scss_File_Generator( $this->theme_name, $this->message_handler );
new Asset_Builder( $this->theme_name, $this->message_handler );
}

/**
* Copies theme files from the theme-template directory into the specified location.
*
* @param bool $force (Optional) Whether theme files will be overidden. If omitted, theme files will only be created if they do not exist. Defaults to false if not specified.
*/
private function copy_theme_files() {
private function copy_theme_files( bool $force = false ) {
Helpers::copy_directory(
__DIR__ . '/../theme-template',
get_theme_root() . '/' . $this->theme_name,
true,
! $force,
function ( string $source_file_path, $destination_file_path ) {
$this->file_string_replacer->replace( $destination_file_path );
}
Expand Down
3 changes: 2 additions & 1 deletion includes/commands/class-build-command.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,9 @@ protected function name(): string {
* $ wp creode-theme:build
*
* @param array $args Not used.
* @param array $assoc_args Not used.
*/
public function __invoke( array $args = array() ) {
public function __invoke( array $args = array(), array $assoc_args = array() ) {
$message_handler = new Command_Message_Handler();

try {
Expand Down
9 changes: 7 additions & 2 deletions includes/commands/class-install-theme-command.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ protected function name(): string {
* [<theme-directory>]
* : The directory name of the theme to install files to.
* If omitted, the active theme will be used.
* [--force]
* : Whether theme files will be overidden.
* If omitted, theme files will only be created if they do not exist.
* Defaults to false if not specified.
*
* ## EXAMPLES
*
Expand All @@ -46,13 +50,14 @@ protected function name(): string {
* $ wp creode-theme:install my-child-theme
*
* @param array $args Optional. Command arguments. [<theme-directory>].
* @param array $assoc_args Optional. Associative array of command options. ['force' => bool].
*/
public function __invoke( array $args = array() ) {
public function __invoke( array $args = array(), array $assoc_args = array() ) {
$theme_name = isset( $args[0] ) ? $args[0] : null;

try {
$installer = new Installer( $theme_name, new Command_Message_Handler() );
$installer->install();
$installer->install( ! empty( $assoc_args['force'] ) );
} catch ( Exception $e ) {
WP_CLI::error( $e->getMessage() );
}
Expand Down