diff --git a/src/Foundation/Console/ClearCompiledCommand.php b/src/Foundation/Console/ClearCompiledCommand.php index 765b8ce9e..5348386e7 100644 --- a/src/Foundation/Console/ClearCompiledCommand.php +++ b/src/Foundation/Console/ClearCompiledCommand.php @@ -1,6 +1,5 @@ (eg: Winter.Blog)} + {command : The name of the command to generate. (eg: create)} + {--force : Overwrite existing files with generated files.}'; /** * The console command description. @@ -48,7 +56,7 @@ protected function prepareVars() $parts = explode('.', $pluginCode); $plugin = array_pop($parts); $author = array_pop($parts); - $command = $this->argument('command-name'); + $command = $this->argument('command'); return [ 'name' => $command, @@ -56,29 +64,4 @@ protected function prepareVars() 'plugin' => $plugin ]; } - - /** - * Get the console command arguments. - * - * @return array - */ - protected function getArguments() - { - return [ - ['plugin', InputArgument::REQUIRED, 'The name of the plugin. Eg: Winter.Blog'], - ['command-name', InputArgument::REQUIRED, 'The name of the command. Eg: MyCommand'], - ]; - } - - /** - * Get the console command options. - * - * @return array - */ - protected function getOptions() - { - return [ - ['force', null, InputOption::VALUE_NONE, 'Overwrite existing files with generated ones.'] - ]; - } } diff --git a/src/Scaffold/Console/CreateComponent.php b/src/Scaffold/Console/CreateComponent.php index dfce572af..67ffe3b6a 100644 --- a/src/Scaffold/Console/CreateComponent.php +++ b/src/Scaffold/Console/CreateComponent.php @@ -1,17 +1,25 @@ (eg: Winter.Blog)} + {component : The name of the component to generate. (eg: Posts)} + {--force : Overwrite existing files with generated files.}'; /** * The console command description. @@ -57,29 +65,4 @@ protected function prepareVars() 'plugin' => $plugin ]; } - - /** - * Get the console command arguments. - * - * @return array - */ - protected function getArguments() - { - return [ - ['plugin', InputArgument::REQUIRED, 'The name of the plugin to create. Eg: Winter.Blog'], - ['component', InputArgument::REQUIRED, 'The name of the component. Eg: Posts'], - ]; - } - - /** - * Get the console command options. - * - * @return array - */ - protected function getOptions() - { - return [ - ['force', null, InputOption::VALUE_NONE, 'Overwrite existing files with generated ones.'] - ]; - } } diff --git a/src/Scaffold/Console/CreateController.php b/src/Scaffold/Console/CreateController.php index 081d2ce99..81cb8c219 100644 --- a/src/Scaffold/Console/CreateController.php +++ b/src/Scaffold/Console/CreateController.php @@ -1,18 +1,27 @@ (eg: Winter.Blog)} + {controller : The name of the controller to generate. (eg: Posts)} + {--force : Overwrite existing files with generated files.} + {--model= : Defines the model name to use. If not provided, the singular name of the controller is used.}'; /** * The console command description. @@ -75,30 +84,4 @@ protected function prepareVars() 'plugin' => $plugin ]; } - - /** - * Get the console command arguments. - * - * @return array - */ - protected function getArguments() - { - return [ - ['plugin', InputArgument::REQUIRED, 'The name of the plugin to create. Eg: Winter.Blog'], - ['controller', InputArgument::REQUIRED, 'The name of the controller. Eg: Posts'], - ]; - } - - /** - * Get the console command options. - * - * @return array - */ - protected function getOptions() - { - return [ - ['force', null, InputOption::VALUE_NONE, 'Overwrite existing files with generated ones.'], - ['model', null, InputOption::VALUE_OPTIONAL, 'Define which model name to use, otherwise the singular controller name is used.'], - ]; - } } diff --git a/src/Scaffold/Console/CreateFormWidget.php b/src/Scaffold/Console/CreateFormWidget.php index f4c0acc63..75b42e3e7 100644 --- a/src/Scaffold/Console/CreateFormWidget.php +++ b/src/Scaffold/Console/CreateFormWidget.php @@ -1,17 +1,25 @@ (eg: Winter.Blog)} + {widget : The name of the form widget to generate. (eg: PostList)} + {--force : Overwrite existing files with generated files.}'; /** * The console command description. @@ -60,29 +68,4 @@ protected function prepareVars() 'plugin' => $plugin ]; } - - /** - * Get the console command arguments. - * - * @return array - */ - protected function getArguments() - { - return [ - ['plugin', InputArgument::REQUIRED, 'The name of the plugin. Eg: Winter.Blog'], - ['widget', InputArgument::REQUIRED, 'The name of the form widget. Eg: PostList'], - ]; - } - - /** - * Get the console command options. - * - * @return array - */ - protected function getOptions() - { - return [ - ['force', null, InputOption::VALUE_NONE, 'Overwrite existing files with generated ones.'], - ]; - } } diff --git a/src/Scaffold/Console/CreateModel.php b/src/Scaffold/Console/CreateModel.php index 6e0b54c44..b4dcef7f0 100644 --- a/src/Scaffold/Console/CreateModel.php +++ b/src/Scaffold/Console/CreateModel.php @@ -1,17 +1,25 @@ (eg: Winter.Blog)} + {model : The name of the model to generate. (eg: Post)} + {--force : Overwrite existing files with generated files.}'; /** * The console command description. @@ -60,29 +68,4 @@ protected function prepareVars() 'plugin' => $plugin ]; } - - /** - * Get the console command arguments. - * - * @return array - */ - protected function getArguments() - { - return [ - ['plugin', InputArgument::REQUIRED, 'The name of the plugin. Eg: Winter.Blog'], - ['model', InputArgument::REQUIRED, 'The name of the model. Eg: Post'], - ]; - } - - /** - * Get the console command options. - * - * @return array - */ - protected function getOptions() - { - return [ - ['force', null, InputOption::VALUE_NONE, 'Overwrite existing files with generated ones.'], - ]; - } } diff --git a/src/Scaffold/Console/CreatePlugin.php b/src/Scaffold/Console/CreatePlugin.php index 8c2821f4e..a17bc128c 100644 --- a/src/Scaffold/Console/CreatePlugin.php +++ b/src/Scaffold/Console/CreatePlugin.php @@ -1,17 +1,24 @@ (eg: Winter.Blog)} + {--force : Overwrite existing files with generated files.}'; /** * The console command description. @@ -65,28 +72,4 @@ protected function prepareVars() 'author' => $authorName, ]; } - - /** - * Get the console command arguments. - * - * @return array - */ - protected function getArguments() - { - return [ - ['plugin', InputArgument::REQUIRED, 'The name of the plugin to create. Eg: Winter.Blog'], - ]; - } - - /** - * Get the console command options. - * - * @return array - */ - protected function getOptions() - { - return [ - ['force', null, InputOption::VALUE_NONE, 'Overwrite existing files with generated ones.'], - ]; - } } diff --git a/src/Scaffold/Console/CreateReportWidget.php b/src/Scaffold/Console/CreateReportWidget.php index 8d8d7aedf..15c9dcf03 100644 --- a/src/Scaffold/Console/CreateReportWidget.php +++ b/src/Scaffold/Console/CreateReportWidget.php @@ -1,17 +1,25 @@ (eg: Winter.Blog)} + {widget : The name of the report widget to generate. (eg: PostViews)} + {--force : Overwrite existing files with generated files.}'; /** * The console command description. @@ -58,29 +66,4 @@ protected function prepareVars() 'plugin' => $plugin ]; } - - /** - * Get the console command arguments. - * - * @return array - */ - protected function getArguments() - { - return [ - ['plugin', InputArgument::REQUIRED, 'The name of the plugin. Eg: Winter.Google'], - ['widget', InputArgument::REQUIRED, 'The name of the report widget. Eg: TopPages'], - ]; - } - - /** - * Get the console command options. - * - * @return array - */ - protected function getOptions() - { - return [ - ['force', null, InputOption::VALUE_NONE, 'Overwrite existing files with generated ones.'], - ]; - } } diff --git a/src/Scaffold/Console/CreateSettings.php b/src/Scaffold/Console/CreateSettings.php index a9bf99b83..25a752c3b 100644 --- a/src/Scaffold/Console/CreateSettings.php +++ b/src/Scaffold/Console/CreateSettings.php @@ -1,17 +1,25 @@ (eg: Winter.Blog)} + {settings : The name of the settings model to generate. (eg: BlogSettings)} + {--force : Overwrite existing files with generated files.}'; /** * The console command description. @@ -57,17 +65,4 @@ protected function prepareVars() 'plugin' => $plugin ]; } - - /** - * Get the console command arguments. - * - * @return array - */ - protected function getArguments() - { - return [ - ['plugin', InputArgument::REQUIRED, 'The name of the plugin. Eg: Winter.Blog'], - ['settings', InputArgument::OPTIONAL, 'The name of the settings model. Eg: Settings'], - ]; - } } diff --git a/src/Scaffold/Console/CreateTheme.php b/src/Scaffold/Console/CreateTheme.php index b4c63eb5a..9a8672940 100644 --- a/src/Scaffold/Console/CreateTheme.php +++ b/src/Scaffold/Console/CreateTheme.php @@ -2,17 +2,24 @@ use Exception; use Winter\Storm\Scaffold\GeneratorCommand; -use Symfony\Component\Console\Input\InputOption; -use Symfony\Component\Console\Input\InputArgument; class CreateTheme extends GeneratorCommand { /** - * The console command name. + * The default command name for lazy loading. + * + * @var string|null + */ + protected static $defaultName = 'create:theme'; + + /** + * The name and signature of this command. * * @var string */ - protected $name = 'create:theme'; + protected $signature = 'create:theme + {theme : The name of the theme to create. (eg: MyTheme)} + {--force : Overwrite existing files with generated files.}'; /** * The console command description. @@ -111,28 +118,4 @@ public function makeStub($stubName) $this->files->put($destinationFile, $destinationContent); } - - /** - * Get the console command arguments. - * - * @return array - */ - protected function getArguments() - { - return [ - ['theme', InputArgument::REQUIRED, 'The code of the theme to create. Eg: example.com'], - ]; - } - - /** - * Get the console command options. - * - * @return array - */ - protected function getOptions() - { - return [ - ['force', null, InputOption::VALUE_NONE, 'Overwrite existing files with generated ones.'], - ]; - } } diff --git a/src/Scaffold/Console/command/command.stub b/src/Scaffold/Console/command/command.stub index e681b0b96..847e811c6 100644 --- a/src/Scaffold/Console/command/command.stub +++ b/src/Scaffold/Console/command/command.stub @@ -9,7 +9,7 @@ class {{studly_name}} extends Command /** * @var string The console command name. */ - protected $name = '{{lower_plugin}}:{{lower_name}}'; + protected static $defaultName = '{{lower_plugin}}:{{lower_name}}'; /** * @var string The console command description. diff --git a/src/Scaffold/GeneratorCommand.php b/src/Scaffold/GeneratorCommand.php index 6445e452e..b0af152c4 100644 --- a/src/Scaffold/GeneratorCommand.php +++ b/src/Scaffold/GeneratorCommand.php @@ -234,28 +234,4 @@ protected function getPluginInput() { return $this->argument('plugin'); } - - /** - * Get the console command arguments. - * - * @return array - */ - protected function getArguments() - { - return [ - ['plugin', InputArgument::REQUIRED, 'The name of the plugin to create. Eg: Winter.Blog'], - ]; - } - - /** - * Get the console command options. - * - * @return array - */ - protected function getOptions() - { - return [ - ['force', null, InputOption::VALUE_NONE, 'Overwrite existing files with generated ones.'], - ]; - } } diff --git a/src/Scaffold/ScaffoldServiceProvider.php b/src/Scaffold/ScaffoldServiceProvider.php index aa8140541..5d50a9cba 100644 --- a/src/Scaffold/ScaffoldServiceProvider.php +++ b/src/Scaffold/ScaffoldServiceProvider.php @@ -1,15 +1,6 @@ CreateTheme::class, - 'command.create.plugin' => CreatePlugin::class, - 'command.create.model' => CreateModel::class, - 'command.create.settings' => CreateSettings::class, - 'command.create.controller' => CreateController::class, - 'command.create.component' => CreateComponent::class, - 'command.create.formwidget' => CreateFormWidget::class, - 'command.create.reportwidget' => CreateReportWidget::class, - 'command.create.command' => CreateCommand::class, + 'command.create.theme' => \Winter\Storm\Scaffold\Console\CreateTheme::class, + 'command.create.plugin' => \Winter\Storm\Scaffold\Console\CreatePlugin::class, + 'command.create.model' => \Winter\Storm\Scaffold\Console\CreateModel::class, + 'command.create.settings' => \Winter\Storm\Scaffold\Console\CreateSettings::class, + 'command.create.controller' => \Winter\Storm\Scaffold\Console\CreateController::class, + 'command.create.component' => \Winter\Storm\Scaffold\Console\CreateComponent::class, + 'command.create.formwidget' => \Winter\Storm\Scaffold\Console\CreateFormWidget::class, + 'command.create.reportwidget' => \Winter\Storm\Scaffold\Console\CreateReportWidget::class, + 'command.create.command' => \Winter\Storm\Scaffold\Console\CreateCommand::class, ]; /**