Skip to content

Commit 8ebf836

Browse files
committed
Show command group on help command
1 parent 8c970ee commit 8ebf836

File tree

6 files changed

+12
-0
lines changed

6 files changed

+12
-0
lines changed

src/Commands/Help.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,13 @@ protected function showCommand(string $commandName) : void
4141
$this->console->getLanguage()->render('cli', 'command') . ': ',
4242
ForegroundColor::green
4343
) . $command->getName());
44+
$value = $command->getGroup();
45+
if ($value !== null) {
46+
CLI::write(CLI::style(
47+
$this->console->getLanguage()->render('cli', 'group') . ': ',
48+
ForegroundColor::green
49+
) . $value);
50+
}
4451
$value = $command->getDescription();
4552
if ($value !== '') {
4653
CLI::write(CLI::style(

src/Languages/en/cli.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
'greet.afternoon' => 'Good afternoon, {0}!',
2323
'greet.evening' => 'Good evening, {0}!',
2424
'greet.morning' => 'Good morning, {0}!',
25+
'group' => 'Group',
2526
'help.description' => 'Shows command usage help.',
2627
'index.description' => 'Shows commands list.',
2728
'index.option.greet' => 'Shows greeting.',

src/Languages/es/cli.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
'greet.afternoon' => '¡Buenas tardes, {0}!',
2323
'greet.evening' => '¡Buenas noches, {0}!',
2424
'greet.morning' => '¡Buenos días, {0}!',
25+
'group' => 'Grupo',
2526
'help.description' => 'Muestra ayuda de uso de comando.',
2627
'index.description' => 'Muestra la lista de comandos.',
2728
'index.option.greet' => 'Muestra saludo.',

src/Languages/pt-br/cli.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
'greet.afternoon' => 'Boa tarde, {0}!',
2323
'greet.evening' => 'Boa noite, {0}!',
2424
'greet.morning' => 'Bom dia, {0}!',
25+
'group' => 'Grupo',
2526
'help.description' => 'Mostra a ajuda de uso do comando.',
2627
'index.description' => 'Mostra a lista de comandos.',
2728
'index.option.greet' => 'Mostra saudação.',

tests/Commands/Foo.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
class Foo extends Command
1616
{
1717
protected string $name = 'foo';
18+
protected string $group = 'Foo';
1819
protected string $description = 'Foo command test';
1920
protected array $options = [
2021
'-o,--opt' => 'Set option as true',

tests/Commands/HelpTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ public function testHelp() : void
2525
self::assertStringNotContainsString('Options', Stdout::getContents());
2626
Stdout::reset();
2727
$console->exec('help foo');
28+
self::assertStringContainsString('Group', Stdout::getContents());
2829
self::assertStringContainsString('Options', Stdout::getContents());
2930
}
3031
}

0 commit comments

Comments
 (0)