Skip to content

Commit

Permalink
Show command group on help command
Browse files Browse the repository at this point in the history
  • Loading branch information
natanfelles committed May 9, 2024
1 parent 8c970ee commit 8ebf836
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/Commands/Help.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,13 @@ protected function showCommand(string $commandName) : void
$this->console->getLanguage()->render('cli', 'command') . ': ',
ForegroundColor::green
) . $command->getName());
$value = $command->getGroup();
if ($value !== null) {
CLI::write(CLI::style(
$this->console->getLanguage()->render('cli', 'group') . ': ',
ForegroundColor::green
) . $value);
}
$value = $command->getDescription();
if ($value !== '') {
CLI::write(CLI::style(
Expand Down
1 change: 1 addition & 0 deletions src/Languages/en/cli.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
'greet.afternoon' => 'Good afternoon, {0}!',
'greet.evening' => 'Good evening, {0}!',
'greet.morning' => 'Good morning, {0}!',
'group' => 'Group',
'help.description' => 'Shows command usage help.',
'index.description' => 'Shows commands list.',
'index.option.greet' => 'Shows greeting.',
Expand Down
1 change: 1 addition & 0 deletions src/Languages/es/cli.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
'greet.afternoon' => '¡Buenas tardes, {0}!',
'greet.evening' => '¡Buenas noches, {0}!',
'greet.morning' => '¡Buenos días, {0}!',
'group' => 'Grupo',
'help.description' => 'Muestra ayuda de uso de comando.',
'index.description' => 'Muestra la lista de comandos.',
'index.option.greet' => 'Muestra saludo.',
Expand Down
1 change: 1 addition & 0 deletions src/Languages/pt-br/cli.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
'greet.afternoon' => 'Boa tarde, {0}!',
'greet.evening' => 'Boa noite, {0}!',
'greet.morning' => 'Bom dia, {0}!',
'group' => 'Grupo',
'help.description' => 'Mostra a ajuda de uso do comando.',
'index.description' => 'Mostra a lista de comandos.',
'index.option.greet' => 'Mostra saudação.',
Expand Down
1 change: 1 addition & 0 deletions tests/Commands/Foo.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
class Foo extends Command
{
protected string $name = 'foo';
protected string $group = 'Foo';
protected string $description = 'Foo command test';
protected array $options = [
'-o,--opt' => 'Set option as true',
Expand Down
1 change: 1 addition & 0 deletions tests/Commands/HelpTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public function testHelp() : void
self::assertStringNotContainsString('Options', Stdout::getContents());
Stdout::reset();
$console->exec('help foo');
self::assertStringContainsString('Group', Stdout::getContents());
self::assertStringContainsString('Options', Stdout::getContents());
}
}

0 comments on commit 8ebf836

Please sign in to comment.