Skip to content

Commit ea91aa2

Browse files
committed
prof: display option alias on render help
1 parent 679f9a0 commit ea91aa2

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

src/Concern/HelperRenderTrait.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use Toolkit\Stdlib\Helper\DataHelper;
1212
use Toolkit\Stdlib\Helper\IntHelper;
1313
use Toolkit\Stdlib\Str;
14+
use function array_merge;
1415
use function array_push;
1516
use function array_shift;
1617
use function count;
@@ -25,6 +26,7 @@
2526
use function strpos;
2627
use function trim;
2728
use function ucfirst;
29+
use function vdump;
2830

2931
/**
3032
* trait HelperRenderTrait
@@ -346,9 +348,13 @@ protected function buildOptsForHelp(array $optDefines, bool $hasShortOpt): array
346348
*/
347349
protected function buildOptHelpLine(string $name, array $opt): array
348350
{
349-
$names = $opt['shorts'];
350-
$names[] = $name;
351+
$names = $opt['shorts'];
352+
// has aliases
353+
if ($opt['aliases']) {
354+
$names = array_merge($names, $opt['aliases']);
355+
}
351356

357+
$names[] = $name;
352358
$helpName = FlagUtil::buildOptHelpName($names);
353359

354360
// show type name.

src/SFlags.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -375,12 +375,12 @@ public function doParse(array $flags): bool
375375
$isShort = true;
376376
$option = substr($p, 1);
377377
// long-opt: (--<opt>)
378-
if (strpos($option, '-') === 0) {
378+
if (str_starts_with($option, '-')) {
379379
$isShort = false;
380380
$option = substr($option, 1);
381381

382382
// long-opt: value specified inline (--<opt>=<value>)
383-
if (strpos($option, '=') !== false) {
383+
if (str_contains($option, '=')) {
384384
[$option, $value] = explode('=', $option, 2);
385385
$hasVal = $value !== '';
386386
}

0 commit comments

Comments
 (0)