From 17481666df7e2f1a26df62cf0be27b1789e1980e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=2E=20Nagy=20Gerg=C5=91?= Date: Fri, 24 Feb 2023 09:27:38 +0100 Subject: [PATCH 1/3] [10.x] Generate default command name based on class name --- .../Foundation/Console/ConsoleMakeCommand.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/Illuminate/Foundation/Console/ConsoleMakeCommand.php b/src/Illuminate/Foundation/Console/ConsoleMakeCommand.php index 20ac6817bd0e..f8fde7b56952 100644 --- a/src/Illuminate/Foundation/Console/ConsoleMakeCommand.php +++ b/src/Illuminate/Foundation/Console/ConsoleMakeCommand.php @@ -4,6 +4,7 @@ use Illuminate\Console\Concerns\CreatesMatchingTest; use Illuminate\Console\GeneratorCommand; +use Illuminate\Support\Str; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputOption; @@ -45,7 +46,13 @@ protected function replaceClass($stub, $name) { $stub = parent::replaceClass($stub, $name); - return str_replace(['dummy:command', '{{ command }}'], $this->option('command'), $stub); + $command = $this->option('command') ?: sprintf( + '%s:%s', + Str::of($this->laravel->getNamespace())->trim('\\')->lower()->replace('\\', '-')->toString(), + Str::of($name)->classBasename()->kebab()->toString() + ); + + return str_replace(['dummy:command', '{{ command }}'], $command, $stub); } /** @@ -94,7 +101,7 @@ protected function getOptions() { return [ ['force', 'f', InputOption::VALUE_NONE, 'Create the class even if the console command already exists'], - ['command', null, InputOption::VALUE_OPTIONAL, 'The terminal command that should be assigned', 'command:name'], + ['command', null, InputOption::VALUE_OPTIONAL, 'The terminal command that should be assigned'], ]; } } From f70e57b5845b9d27abe0cd34c2569c47da04b563 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Sat, 25 Feb 2023 11:54:41 +0530 Subject: [PATCH 2/3] formatting --- src/Illuminate/Foundation/Console/ConsoleMakeCommand.php | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/Illuminate/Foundation/Console/ConsoleMakeCommand.php b/src/Illuminate/Foundation/Console/ConsoleMakeCommand.php index f8fde7b56952..f161c8243140 100644 --- a/src/Illuminate/Foundation/Console/ConsoleMakeCommand.php +++ b/src/Illuminate/Foundation/Console/ConsoleMakeCommand.php @@ -46,11 +46,7 @@ protected function replaceClass($stub, $name) { $stub = parent::replaceClass($stub, $name); - $command = $this->option('command') ?: sprintf( - '%s:%s', - Str::of($this->laravel->getNamespace())->trim('\\')->lower()->replace('\\', '-')->toString(), - Str::of($name)->classBasename()->kebab()->toString() - ); + $command = $this->option('command') ?: 'app:'.Str::of($name)->classBasename()->kebab()->value(); return str_replace(['dummy:command', '{{ command }}'], $command, $stub); } From 58545ed7973f099a30b6b17579b92f3c4ecdc4d9 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Sat, 25 Feb 2023 11:56:00 +0530 Subject: [PATCH 3/3] formatting --- src/Illuminate/Foundation/Console/ConsoleMakeCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Illuminate/Foundation/Console/ConsoleMakeCommand.php b/src/Illuminate/Foundation/Console/ConsoleMakeCommand.php index f161c8243140..d4e28645ea8c 100644 --- a/src/Illuminate/Foundation/Console/ConsoleMakeCommand.php +++ b/src/Illuminate/Foundation/Console/ConsoleMakeCommand.php @@ -97,7 +97,7 @@ protected function getOptions() { return [ ['force', 'f', InputOption::VALUE_NONE, 'Create the class even if the console command already exists'], - ['command', null, InputOption::VALUE_OPTIONAL, 'The terminal command that should be assigned'], + ['command', null, InputOption::VALUE_OPTIONAL, 'The terminal command that will be used to invoke the class'], ]; } }