Skip to content

Commit ec60cd4

Browse files
committed
fix: update help UI
1 parent b5fecc1 commit ec60cd4

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

src/Sprout/App.php

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -334,20 +334,35 @@ protected function renderHelpView(Command $command)
334334
$paramsHelp = '';
335335
$argumentsHelp = '';
336336

337+
if (count($command->getHelp()['arguments']) === 0) {
338+
$argumentsHelp = " This command has no arguments.\n";
339+
}
340+
337341
foreach ($command->getHelp()['arguments'] as $helpKey => $helpValue) {
338342
$argumentsHelp .= " $helpKey: {$helpValue['description']}\n";
339343
}
340344

341345
foreach ($command->getHelp()['params'] as $helpKey => $helpValue) {
342-
$paramsHelp .= " $helpKey: {$helpValue['description']}\n";
346+
$paramsHelp .= (($helpValue['short'] !== null) ? " -{$helpValue['short']}," : ' ') .
347+
" --{$helpValue['long']}: {$helpValue['description']}\n";
348+
}
349+
350+
$options = $command->getHelp();
351+
$arguments = $options['arguments'];
352+
$params = count($options['params']) > 0 ? '[--options...]' : '';
353+
354+
$usageArguments = '';
355+
356+
foreach ($arguments as $argKey => $argValue) {
357+
$usageArguments .= " [$argKey]";
343358
}
344359

345360
echo <<<HELP
346361
Description:
347362
{$command->getDescription()}
348363
349364
Usage:
350-
{$command->getName()} [options] [--] [<packages>...]
365+
{$command->getName()}{$usageArguments} {$params}
351366
352367
Arguments:
353368
$argumentsHelp

0 commit comments

Comments
 (0)