diff --git a/src/Command/PluginCommand.php b/src/Command/PluginCommand.php index 9afc3558f..9cc30f277 100644 --- a/src/Command/PluginCommand.php +++ b/src/Command/PluginCommand.php @@ -369,6 +369,15 @@ public function buildOptionParser(ConsoleOptionParser $parser): ConsoleOptionPar ])->addOption('composer', [ 'default' => ROOT . DS . 'composer.phar', 'help' => 'The path to the composer executable.', + ])->addOption('force', [ + 'short' => 'f', + 'boolean' => true, + 'help' => 'Force overwriting existing files without prompting.', + ])->addOption('theme', [ + 'short' => 't', + 'help' => 'The theme to use when baking code.', + 'default' => Configure::read('Bake.theme') ?? '', + 'choices' => $this->_getBakeThemes(), ]); return $parser; diff --git a/src/Plugin.php b/src/Plugin.php index efd8f90da..3798f9e7a 100644 --- a/src/Plugin.php +++ b/src/Plugin.php @@ -115,6 +115,7 @@ protected function discoverCommands(CommandCollection $commands): CommandCollect * @param string $path The path to look in. * @return string[] * @phpstan-return class-string<\Bake\Command\BakeCommand>[] + * @psalm-suppress InvalidReturnType */ protected function findInPath(string $namespace, string $path): array { @@ -152,6 +153,7 @@ protected function findInPath(string $namespace, string $path): array $candidates[$class::defaultName()] = $class; } + /** @psalm-suppress InvalidReturnStatement */ return $candidates; } } diff --git a/src/Utility/CommonOptionsTrait.php b/src/Utility/CommonOptionsTrait.php index c58310476..2ec2d448d 100644 --- a/src/Utility/CommonOptionsTrait.php +++ b/src/Utility/CommonOptionsTrait.php @@ -73,12 +73,11 @@ protected function extractCommonProperties(Arguments $args): void } /** - * Set common options used by all bake tasks. + * Get available bake themes * - * @param \Cake\Console\ConsoleOptionParser $parser Options parser. - * @return \Cake\Console\ConsoleOptionParser + * @return array */ - protected function _setCommonOptions(ConsoleOptionParser $parser): ConsoleOptionParser + protected function _getBakeThemes(): array { $bakeThemes = []; $templates = 'templates' . DS . 'bake'; @@ -89,6 +88,17 @@ protected function _setCommonOptions(ConsoleOptionParser $parser): ConsoleOption } } + return $bakeThemes; + } + + /** + * Set common options used by all bake tasks. + * + * @param \Cake\Console\ConsoleOptionParser $parser Options parser. + * @return \Cake\Console\ConsoleOptionParser + */ + protected function _setCommonOptions(ConsoleOptionParser $parser): ConsoleOptionParser + { $parser->addOption('plugin', [ 'short' => 'p', 'help' => 'Plugin to bake into.', @@ -104,7 +114,7 @@ protected function _setCommonOptions(ConsoleOptionParser $parser): ConsoleOption 'short' => 't', 'help' => 'The theme to use when baking code.', 'default' => Configure::read('Bake.theme') ?? '', - 'choices' => $bakeThemes, + 'choices' => $this->_getBakeThemes(), ]); return $parser;