Skip to content

Commit 3b7f6d0

Browse files
[10.x] Generate default command name based on class name (#46256)
* [10.x] Generate default command name based on class name * formatting * formatting --------- Co-authored-by: Taylor Otwell <[email protected]>
1 parent 2c4a4e7 commit 3b7f6d0

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/Illuminate/Foundation/Console/ConsoleMakeCommand.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Illuminate\Console\Concerns\CreatesMatchingTest;
66
use Illuminate\Console\GeneratorCommand;
7+
use Illuminate\Support\Str;
78
use Symfony\Component\Console\Attribute\AsCommand;
89
use Symfony\Component\Console\Input\InputArgument;
910
use Symfony\Component\Console\Input\InputOption;
@@ -45,7 +46,9 @@ protected function replaceClass($stub, $name)
4546
{
4647
$stub = parent::replaceClass($stub, $name);
4748

48-
return str_replace(['dummy:command', '{{ command }}'], $this->option('command'), $stub);
49+
$command = $this->option('command') ?: 'app:'.Str::of($name)->classBasename()->kebab()->value();
50+
51+
return str_replace(['dummy:command', '{{ command }}'], $command, $stub);
4952
}
5053

5154
/**
@@ -94,7 +97,7 @@ protected function getOptions()
9497
{
9598
return [
9699
['force', 'f', InputOption::VALUE_NONE, 'Create the class even if the console command already exists'],
97-
['command', null, InputOption::VALUE_OPTIONAL, 'The terminal command that should be assigned', 'command:name'],
100+
['command', null, InputOption::VALUE_OPTIONAL, 'The terminal command that will be used to invoke the class'],
98101
];
99102
}
100103
}

0 commit comments

Comments
 (0)