Skip to content

Commit 31531bb

Browse files
committed
refactor: refactoring the console
1 parent 5233c1f commit 31531bb

14 files changed

Lines changed: 417 additions & 362 deletions

src/Console/Command.php

Lines changed: 28 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -5,30 +5,30 @@
55
namespace Bow\Console;
66

77
use ErrorException;
8-
use Bow\Support\Str;
98
use Bow\Console\Command\ReplCommand;
109
use Bow\Console\Command\ClearCommand;
11-
use Bow\Console\Command\ModelCommand;
1210
use Bow\Console\Command\SeederCommand;
1311
use Bow\Console\Command\ServerCommand;
1412
use Bow\Console\Command\WorkerCommand;
15-
use Bow\Console\Command\ConsoleCommand;
16-
use Bow\Console\Command\ServiceCommand;
1713
use Bow\Console\Command\AppEventCommand;
18-
use Bow\Console\Command\ProducerCommand;
19-
use Bow\Console\Command\ExceptionCommand;
20-
use Bow\Console\Command\MessagingCommand;
2114
use Bow\Console\Command\MigrationCommand;
22-
use Bow\Console\Command\ControllerCommand;
23-
use Bow\Console\Command\MiddlewareCommand;
2415
use Bow\Console\Command\ValidationCommand;
2516
use Bow\Console\Command\GenerateKeyCommand;
26-
use Bow\Console\Command\ConfigurationCommand;
27-
use Bow\Console\Command\EventListenerCommand;
2817
use Bow\Console\Command\GenerateCacheCommand;
18+
use Bow\Console\Command\GenerateModelCommand;
2919
use Bow\Console\Command\GenerateQueueCommand;
20+
use Bow\Console\Command\GenerateSeederCommand;
21+
use Bow\Console\Command\GenerateConsoleCommand;
22+
use Bow\Console\Command\GenerateServiceCommand;
3023
use Bow\Console\Command\GenerateSessionCommand;
24+
use Bow\Console\Command\GenerateProducerCommand;
25+
use Bow\Console\Command\GenerateExceptionCommand;
26+
use Bow\Console\Command\GenerateMessagingCommand;
27+
use Bow\Console\Command\GenerateControllerCommand;
28+
use Bow\Console\Command\GenerateMiddlewareCommand;
3129
use Bow\Console\Command\GenerateNotificationCommand;
30+
use Bow\Console\Command\GenerateConfigurationCommand;
31+
use Bow\Console\Command\GenerateEventListenerCommand;
3232
use Bow\Console\Command\GenerateResourceControllerCommand;
3333

3434
class Command extends AbstractCommand
@@ -39,25 +39,28 @@ class Command extends AbstractCommand
3939
* @var array
4040
*/
4141
private array $commands = [
42-
"clear" => ClearCommand::class,
43-
"migration" => MigrationCommand::class,
44-
"migrate" => MigrationCommand::class,
4542
"seed" => SeederCommand::class,
43+
"seed:table" => GenerateSeederCommand::class,
4644
"serve" => ServerCommand::class,
47-
"add:controller" => ControllerCommand::class,
48-
"add:configuration" => ConfigurationCommand::class,
49-
"add:exception" => ExceptionCommand::class,
50-
"add:middleware" => MiddlewareCommand::class,
45+
"clear" => ClearCommand::class,
46+
"migrate" => MigrationCommand::class,
47+
"migration:migrate" => MigrationCommand::class,
48+
"migration:rollback" => MigrationCommand::class,
49+
"migration:reset" => MigrationCommand::class,
50+
"add:controller" => GenerateControllerCommand::class,
51+
"add:configuration" => GenerateConfigurationCommand::class,
52+
"add:exception" => GenerateExceptionCommand::class,
53+
"add:middleware" => GenerateMiddlewareCommand::class,
5154
"add:migration" => MigrationCommand::class,
52-
"add:model" => ModelCommand::class,
55+
"add:model" => GenerateModelCommand::class,
5356
"add:seeder" => SeederCommand::class,
54-
"add:service" => ServiceCommand::class,
57+
"add:service" => GenerateServiceCommand::class,
5558
"add:validation" => ValidationCommand::class,
5659
"add:event" => AppEventCommand::class,
57-
"add:listener" => EventListenerCommand::class,
58-
"add:producer" => ProducerCommand::class,
59-
"add:command" => ConsoleCommand::class,
60-
"add:message" => MessagingCommand::class,
60+
"add:listener" => GenerateEventListenerCommand::class,
61+
"add:producer" => GenerateProducerCommand::class,
62+
"add:command" => GenerateConsoleCommand::class,
63+
"add:message" => GenerateMessagingCommand::class,
6164
"run:console" => ReplCommand::class,
6265
"run:server" => ServerCommand::class,
6366
"run:worker" => WorkerCommand::class,
@@ -97,7 +100,7 @@ public function call(string $command, string $action, ...$rest): mixed
97100
$this->throwFailsCommand("The command $command not found !");
98101
}
99102

100-
if (!preg_match('/^(clear|migrate|migration):/', $command)) {
103+
if (!preg_match('/^(migrate|migration)/', $command)) {
101104
$method = "run";
102105
} else {
103106
$method = $action;

src/Console/Command/ConfigurationCommand.php renamed to src/Console/Command/GenerateConfigurationCommand.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,8 @@
77
use Bow\Console\AbstractCommand;
88
use Bow\Console\Color;
99
use Bow\Console\Generator;
10-
use JetBrains\PhpStorm\NoReturn;
1110

12-
class ConfigurationCommand extends AbstractCommand
11+
class GenerateConfigurationCommand extends AbstractCommand
1312
{
1413
/**
1514
* Add configuration

src/Console/Command/ConsoleCommand.php renamed to src/Console/Command/GenerateConsoleCommand.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,8 @@
66

77
use Bow\Console\AbstractCommand;
88
use Bow\Console\Generator;
9-
use JetBrains\PhpStorm\NoReturn;
109

11-
class ConsoleCommand extends AbstractCommand
10+
class GenerateConsoleCommand extends AbstractCommand
1211
{
1312
/**
1413
* Add service

src/Console/Command/ControllerCommand.php renamed to src/Console/Command/GenerateControllerCommand.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,8 @@
66

77
use Bow\Console\AbstractCommand;
88
use Bow\Console\Generator;
9-
use JetBrains\PhpStorm\NoReturn;
109

11-
class ControllerCommand extends AbstractCommand
10+
class GenerateControllerCommand extends AbstractCommand
1211
{
1312
/**
1413
* The add controller command

src/Console/Command/EventListenerCommand.php renamed to src/Console/Command/GenerateEventListenerCommand.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,8 @@
66

77
use Bow\Console\AbstractCommand;
88
use Bow\Console\Generator;
9-
use JetBrains\PhpStorm\NoReturn;
109

11-
class EventListenerCommand extends AbstractCommand
10+
class GenerateEventListenerCommand extends AbstractCommand
1211
{
1312
/**
1413
* Add event

src/Console/Command/ExceptionCommand.php renamed to src/Console/Command/GenerateExceptionCommand.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,8 @@
66

77
use Bow\Console\AbstractCommand;
88
use Bow\Console\Generator;
9-
use JetBrains\PhpStorm\NoReturn;
109

11-
class ExceptionCommand extends AbstractCommand
10+
class GenerateExceptionCommand extends AbstractCommand
1211
{
1312
/**
1413
* Add middleware

src/Console/Command/MessagingCommand.php renamed to src/Console/Command/GenerateMessagingCommand.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,8 @@
77
use Bow\Console\AbstractCommand;
88
use Bow\Console\Color;
99
use Bow\Console\Generator;
10-
use JetBrains\PhpStorm\NoReturn;
1110

12-
class MessagingCommand extends AbstractCommand
11+
class GenerateMessagingCommand extends AbstractCommand
1312
{
1413
/**
1514
* Generate session

src/Console/Command/MiddlewareCommand.php renamed to src/Console/Command/GenerateMiddlewareCommand.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,8 @@
77
use Bow\Console\AbstractCommand;
88
use Bow\Console\Color;
99
use Bow\Console\Generator;
10-
use JetBrains\PhpStorm\NoReturn;
1110

12-
class MiddlewareCommand extends AbstractCommand
11+
class GenerateMiddlewareCommand extends AbstractCommand
1312
{
1413
/**
1514
* Add middleware

src/Console/Command/ModelCommand.php renamed to src/Console/Command/GenerateModelCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
use Bow\Console\Color;
99
use Bow\Console\Generator;
1010

11-
class ModelCommand extends AbstractCommand
11+
class GenerateModelCommand extends AbstractCommand
1212
{
1313
/**
1414
* Add Model

src/Console/Command/ProducerCommand.php renamed to src/Console/Command/GenerateProducerCommand.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,8 @@
77
use Bow\Console\AbstractCommand;
88
use Bow\Console\Color;
99
use Bow\Console\Generator;
10-
use JetBrains\PhpStorm\NoReturn;
1110

12-
class ProducerCommand extends AbstractCommand
11+
class GenerateProducerCommand extends AbstractCommand
1312
{
1413
/**
1514
* Add producer

0 commit comments

Comments
 (0)