Skip to content

Commit

Permalink
Make help_description into help_description_even/odd and make help_it…
Browse files Browse the repository at this point in the history
…em into help_item_even/odd
  • Loading branch information
kodie authored and adhocore committed Nov 26, 2024
1 parent 3c04803 commit a1cd34f
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 28 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -459,12 +459,14 @@ There are a number of pre-defined built-in styles that allows you granular custo
- comment
- error
- help_category
- help_description
- help_description_even
- help_description_odd
- help_example
- help_footer
- help_group
- help_header
- help_item
- help_item_even
- help_item_odd
- help_summary
- help_text
- info
Expand Down
11 changes: 8 additions & 3 deletions src/Helper/OutputHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -197,16 +197,21 @@ protected function showHelp(string $for, array $items, string $header = '', stri
$group = $lastGroup = null;

$withDefault = $for === 'Options' || $for === 'Arguments';
foreach ($this->sortItems($items, $padLen, $for) as $item) {
foreach (array_values($this->sortItems($items, $padLen, $for)) as $idx => $item) {
$name = $this->getName($item);
if ($for === 'Commands' && $lastGroup !== $group = $item->group()) {
$this->writer->help_group($group ?: '*', true);
$lastGroup = $group;
}
$desc = str_replace(["\r\n", "\n"], str_pad("\n", $padLen + $space + 3), $item->desc($withDefault));

$this->writer->help_item(' ' . str_pad($name, $padLen + $space));
$this->writer->help_description($desc, true);
if ($idx % 2 == 0) {
$this->writer->help_item_even(' ' . str_pad($name, $padLen + $space));
$this->writer->help_description_even($desc, true);
} else {
$this->writer->help_item_odd(' ' . str_pad($name, $padLen + $space));
$this->writer->help_description_odd($desc, true);
}
}

if ($footer) {
Expand Down
6 changes: 4 additions & 2 deletions src/IO/Interactor.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,12 +150,14 @@
* @method Writer greenBgWhite($text, $eol = false)
* @method Writer greenBgYellow($text, $eol = false)
* @method Writer help_category($text, $eol = false)
* @method Writer help_description($text, $eol = false)
* @method Writer help_description_even($text, $eol = false)
* @method Writer help_description_odd($text, $eol = false)
* @method Writer help_example($text, $eol = false)
* @method Writer help_footer($text, $eol = false)
* @method Writer help_group($text, $eol = false)
* @method Writer help_header($text, $eol = false)
* @method Writer help_item($text, $eol = false)
* @method Writer help_item_even($text, $eol = false)
* @method Writer help_item_odd($text, $eol = false)
* @method Writer help_summary($text, $eol = false)
* @method Writer help_text($text, $eol = false)
* @method Writer info($text, $eol = false)
Expand Down
40 changes: 21 additions & 19 deletions src/Output/Color.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,25 +54,27 @@ class Color

/** @var array Custom styles */
protected static array $styles = [
'answer' => ['fg' => 37, 'mod' => 2],
'choice' => ['fg' => 36],
'comment' => ['fg' => 37, 'mod' => 2],
'error' => ['fg' => 31],
'help_category' => ['fg' => 32, 'mod' => 1],
'help_description' => ['fg' => 37, 'mod' => 2],
'help_example' => ['fg' => 33],
'help_footer' => ['fg' => 33],
'help_group' => ['fg' => 33, 'mod' => 1],
'help_header' => ['fg' => 37, 'mod' => 1],
'help_item' => ['fg' => 37, 'mod' => 1],
'help_summary' => ['fg' => 37, 'mod' => 2],
'help_text' => ['fg' => 37, 'mod' => 1],
'info' => ['fg' => 34],
'logo' => ['fg' => 37],
'ok' => ['fg' => 32],
'question' => ['fg' => 33],
'version' => ['fg' => 37, 'mod' => 1],
'warn' => ['fg' => 33],
'answer' => ['fg' => 37, 'mod' => 2],
'choice' => ['fg' => 36],
'comment' => ['fg' => 37, 'mod' => 2],
'error' => ['fg' => 31],
'help_category' => ['fg' => 32, 'mod' => 1],
'help_description_even' => ['fg' => 37, 'mod' => 2],
'help_description_odd' => ['fg' => 37, 'mod' => 2],
'help_example' => ['fg' => 33],
'help_footer' => ['fg' => 33],
'help_group' => ['fg' => 33, 'mod' => 1],
'help_header' => ['fg' => 37, 'mod' => 1],
'help_item_even' => ['fg' => 37, 'mod' => 1],
'help_item_odd' => ['fg' => 37, 'mod' => 1],
'help_summary' => ['fg' => 37, 'mod' => 2],
'help_text' => ['fg' => 37, 'mod' => 1],
'info' => ['fg' => 34],
'logo' => ['fg' => 37],
'ok' => ['fg' => 32],
'question' => ['fg' => 33],
'version' => ['fg' => 37, 'mod' => 1],
'warn' => ['fg' => 33],
];

/**
Expand Down
6 changes: 4 additions & 2 deletions src/Output/Writer.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,12 +146,14 @@
* @method Writer greenBgWhite($text, $eol = false)
* @method Writer greenBgYellow($text, $eol = false)
* @method Writer help_category($text, $eol = false)
* @method Writer help_description($text, $eol = false)
* @method Writer help_description_even($text, $eol = false)
* @method Writer help_description_odd($text, $eol = false)
* @method Writer help_example($text, $eol = false)
* @method Writer help_footer($text, $eol = false)
* @method Writer help_group($text, $eol = false)
* @method Writer help_header($text, $eol = false)
* @method Writer help_item($text, $eol = false)
* @method Writer help_item_even($text, $eol = false)
* @method Writer help_item_odd($text, $eol = false)
* @method Writer help_summary($text, $eol = false)
* @method Writer help_text($text, $eol = false)
* @method Writer info($text, $eol = false)
Expand Down

0 comments on commit a1cd34f

Please sign in to comment.