Skip to content

Commit

Permalink
Merge pull request #1008 from cakephp/feat/command
Browse files Browse the repository at this point in the history
Add getDescription() to command template
  • Loading branch information
markstory authored Oct 8, 2024
2 parents dc3ec51 + 8be277c commit ccb0c78
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 6 deletions.
15 changes: 12 additions & 3 deletions templates/bake/Command/command.twig
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,16 @@
*/
class {{ name }}Command extends Command
{
/**
* Get the command description.
*
* @return string
*/
public static function getDescription(): string
{
return 'Command description here.';
}

/**
* Hook method for defining this command's option parser.
*
Expand All @@ -37,9 +47,8 @@ class {{ name }}Command extends Command
*/
public function buildOptionParser(ConsoleOptionParser $parser): ConsoleOptionParser
{
$parser = parent::buildOptionParser($parser);

return $parser;
return parent::buildOptionParser($parser)
->setDescription(static::getDescription());
}

/**
Expand Down
15 changes: 12 additions & 3 deletions tests/comparisons/Command/testBakePlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,16 @@
*/
class ExampleCommand extends Command
{
/**
* Get the command description.
*
* @return string
*/
public static function getDescription(): string
{
return 'Command description here.';
}

/**
* Hook method for defining this command's option parser.
*
Expand All @@ -22,9 +32,8 @@ class ExampleCommand extends Command
*/
public function buildOptionParser(ConsoleOptionParser $parser): ConsoleOptionParser
{
$parser = parent::buildOptionParser($parser);

return $parser;
return parent::buildOptionParser($parser)
->setDescription(static::getDescription());
}

/**
Expand Down

0 comments on commit ccb0c78

Please sign in to comment.