Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 5c4326d

Browse files
committed
fix: sort command names on display help
1 parent c706e9d commit 5c4326d

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

‎libs/cli-utils/src/App.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
use function is_array;
2222
use function is_object;
2323
use function is_string;
24+
use function ksort;
2425
use function method_exists;
2526
use function str_pad;
2627
use function strlen;
@@ -290,12 +291,14 @@ public function displayHelp(string $err = ''): void
290291
echo Color::render("<red>ERROR</red>: $err\n\n");
291292
}
292293

293-
$commandWidth = $this->keyWidth;
294294
// help
295+
$len = $this->keyWidth;
295296
$help = "Welcome to the Lite Console Application.\n\n<comment>Available Commands:</comment>\n";
297+
$data = $this->messages;
298+
ksort($data);
296299

297-
foreach ($this->messages as $command => $item) {
298-
$command = str_pad($command, $commandWidth, '');
300+
foreach ($data as $command => $item) {
301+
$command = str_pad($command, $len, '');
299302
$desc = $item['desc'] ? ucfirst($item['desc']) : 'No description for the command';
300303
$help .= "$command$desc\n";
301304
}
@@ -322,11 +325,12 @@ public function displayCommandHelp(string $name): void
322325
];
323326
} else {
324327
$checkVar = true;
328+
$userHelp = $config['help'];
325329

326330
$nodes = [
327331
ucfirst($config['desc']),
328332
"<comment>Usage:</comment> \n" . ($config['usage'] ?: $usage),
329-
$config['help']
333+
$userHelp ? $userHelp . "\n" : ''
330334
];
331335
}
332336

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /