Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add default name to commands for lazy loading #63

Merged
merged 4 commits into from
Dec 17, 2021
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
1 change: 0 additions & 1 deletion src/Foundation/Console/ClearCompiledCommand.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?php namespace Winter\Storm\Foundation\Console;

use Illuminate\Filesystem\Filesystem;
use Illuminate\Foundation\Console\ClearCompiledCommand as ClearCompiledCommandBase;

class ClearCompiledCommand extends ClearCompiledCommandBase
Expand Down
14 changes: 0 additions & 14 deletions src/Foundation/Console/KeyGenerateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,6 @@

class KeyGenerateCommand extends KeyGenerateCommandBase
{
/**
* The console command name.
*
* @var string
*/
protected $name = 'key:generate';

/**
* The console command description.
*
* @var string
*/
protected $description = "Set the application key";

/**
* Create a new key generator command.
*
Expand Down
43 changes: 13 additions & 30 deletions src/Scaffold/Console/CreateCommand.php
Original file line number Diff line number Diff line change
@@ -1,17 +1,25 @@
<?php namespace Winter\Storm\Scaffold\Console;

use Winter\Storm\Scaffold\GeneratorCommand;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputArgument;

class CreateCommand extends GeneratorCommand
{
/**
* The console command name.
* The default command name for lazy loading.
*
* @var string|null
*/
protected static $defaultName = 'create:command';

/**
* The name and signature of this command.
*
* @var string
*/
protected $name = 'create:command';
protected $signature = 'create:command
{plugin : The name of the plugin. <info>(eg: Winter.Blog)</info>}
{command : The name of the command to generate. <info>(eg: create)</info>}
{--force : Overwrite existing files with generated files.}';

/**
* The console command description.
Expand Down Expand Up @@ -48,37 +56,12 @@ 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,
'author' => $author,
'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.']
];
}
}
41 changes: 12 additions & 29 deletions src/Scaffold/Console/CreateComponent.php
Original file line number Diff line number Diff line change
@@ -1,17 +1,25 @@
<?php namespace Winter\Storm\Scaffold\Console;

use Winter\Storm\Scaffold\GeneratorCommand;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputArgument;

class CreateComponent extends GeneratorCommand
{
/**
* The console command name.
* The default command name for lazy loading.
*
* @var string|null
*/
protected static $defaultName = 'create:component';

/**
* The name and signature of this command.
*
* @var string
*/
protected $name = 'create:component';
protected $signature = 'create:component
{plugin : The name of the plugin. <info>(eg: Winter.Blog)</info>}
{component : The name of the component to generate. <info>(eg: Posts)</info>}
{--force : Overwrite existing files with generated files.}';

/**
* The console command description.
Expand Down Expand Up @@ -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.']
];
}
}
43 changes: 13 additions & 30 deletions src/Scaffold/Console/CreateController.php
Original file line number Diff line number Diff line change
@@ -1,18 +1,27 @@
<?php namespace Winter\Storm\Scaffold\Console;

use Winter\Storm\Scaffold\GeneratorCommand;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputArgument;
use Winter\Storm\Support\Str;

class CreateController extends GeneratorCommand
{
/**
* The console command name.
* The default command name for lazy loading.
*
* @var string|null
*/
protected static $defaultName = 'create:controller';

/**
* The name and signature of this command.
*
* @var string
*/
protected $name = 'create:controller';
protected $signature = 'create:controller
{plugin : The name of the plugin. <info>(eg: Winter.Blog)</info>}
{controller : The name of the controller to generate. <info>(eg: Posts)</info>}
{--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.
Expand Down Expand Up @@ -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.'],
];
}
}
41 changes: 12 additions & 29 deletions src/Scaffold/Console/CreateFormWidget.php
Original file line number Diff line number Diff line change
@@ -1,17 +1,25 @@
<?php namespace Winter\Storm\Scaffold\Console;

use Winter\Storm\Scaffold\GeneratorCommand;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputArgument;

class CreateFormWidget extends GeneratorCommand
{
/**
* The console command name.
* The default command name for lazy loading.
*
* @var string|null
*/
protected static $defaultName = 'create:formwidget';

/**
* The name and signature of this command.
*
* @var string
*/
protected $name = 'create:formwidget';
protected $signature = 'create:formwidget
{plugin : The name of the plugin. <info>(eg: Winter.Blog)</info>}
{widget : The name of the form widget to generate. <info>(eg: PostList)</info>}
{--force : Overwrite existing files with generated files.}';

/**
* The console command description.
Expand Down Expand Up @@ -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.'],
];
}
}
41 changes: 12 additions & 29 deletions src/Scaffold/Console/CreateModel.php
Original file line number Diff line number Diff line change
@@ -1,17 +1,25 @@
<?php namespace Winter\Storm\Scaffold\Console;

use Winter\Storm\Scaffold\GeneratorCommand;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputArgument;

class CreateModel extends GeneratorCommand
{
/**
* The console command name.
* The default command name for lazy loading.
*
* @var string|null
*/
protected static $defaultName = 'create:model';

/**
* The name and signature of this command.
*
* @var string
*/
protected $name = 'create:model';
protected $signature = 'create:model
{plugin : The name of the plugin. <info>(eg: Winter.Blog)</info>}
{model : The name of the model to generate. <info>(eg: Post)</info>}
{--force : Overwrite existing files with generated files.}';

/**
* The console command description.
Expand Down Expand Up @@ -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.'],
];
}
}
39 changes: 11 additions & 28 deletions src/Scaffold/Console/CreatePlugin.php
Original file line number Diff line number Diff line change
@@ -1,17 +1,24 @@
<?php namespace Winter\Storm\Scaffold\Console;

use Winter\Storm\Scaffold\GeneratorCommand;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputArgument;

class CreatePlugin extends GeneratorCommand
{
/**
* The console command name.
* The default command name for lazy loading.
*
* @var string|null
*/
protected static $defaultName = 'create:plugin';

/**
* The name and signature of this command.
*
* @var string
*/
protected $name = 'create:plugin';
protected $signature = 'create:plugin
{plugin : The name of the plugin to create. <info>(eg: Winter.Blog)</info>}
{--force : Overwrite existing files with generated files.}';

/**
* The console command description.
Expand Down Expand Up @@ -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.'],
];
}
}
Loading