Skip to content

Commit

Permalink
πŸ§‘β€πŸ’» Improve command generation styling
Browse files Browse the repository at this point in the history
  • Loading branch information
Log1x committed Jul 18, 2024
1 parent 92b1527 commit dcd8f15
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 7 deletions.
6 changes: 5 additions & 1 deletion src/Console/Commands/MakeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,11 @@ protected function replaceClass($stub, $name)

$command = $this->option('command') ?: Str::of($name)->classBasename()->kebab()->value();

return str_replace(['dummy:command', '{{ command }}'], $command, $stub);
$title = Str::of($command)->replace('-', ' ')->apa();

$stub = str_replace(['dummy:command', '{{ command }}', '{{ title }}'], [$command, $command, $title], $stub);

return $stub;
}

/**
Expand Down
6 changes: 5 additions & 1 deletion src/Console/Commands/MakeMenuCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,11 @@ protected function replaceClass($stub, $name)

$command = $this->option('command') ?: Str::of($name)->classBasename()->kebab()->value();

return str_replace(['dummy:command', '{{ command }}'], $command, $stub);
$title = Str::of($command)->replace('-', ' ')->apa();

$stub = str_replace(['dummy:command', '{{ command }}', '{{ title }}'], [$command, $command, $title], $stub);

return $stub;
}

/**
Expand Down
6 changes: 5 additions & 1 deletion src/Console/Commands/MakeSlashCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,11 @@ protected function replaceClass($stub, $name)

$command = $this->option('command') ?: Str::of($name)->classBasename()->kebab()->value();

return str_replace(['dummy:command', '{{ command }}'], $command, $stub);
$title = Str::of($command)->replace('-', ' ')->apa();

$stub = str_replace(['dummy:command', '{{ command }}', '{{ title }}'], [$command, $command, $title], $stub);

return $stub;
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/Console/Commands/stubs/command.stub
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class {{ class }} extends Command
*
* @var string
*/
protected $description = 'The {{ command }} command.';
protected $description = 'The {{ title }} command.';

/**
* Determines whether the command requires admin permissions.
Expand All @@ -46,7 +46,7 @@ class {{ class }} extends Command
{
return $this
->message()
->title('{{ class }}')
->title('{{ title }}')
->content('Hello world!')
->button('πŸ‘‹', route: 'wave')
->send($message);
Expand Down
4 changes: 2 additions & 2 deletions src/Console/Commands/stubs/slash-command.stub
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class {{ class }} extends SlashCommand
*
* @var string
*/
protected $description = 'The {{ command }} slash command.';
protected $description = 'The {{ title }} slash command.';

/**
* The command options.
Expand Down Expand Up @@ -60,7 +60,7 @@ class {{ class }} extends SlashCommand
$interaction->respondWithMessage(
$this
->message()
->title('{{ class }}')
->title('{{ title }}')
->content('Hello world!')
->button('πŸ‘‹', route: 'wave')
->build()
Expand Down

0 comments on commit dcd8f15

Please sign in to comment.