diff --git a/README.md b/README.md index 761c862..a59086c 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/src/Helper/OutputHelper.php b/src/Helper/OutputHelper.php index df518c8..21e9583 100644 --- a/src/Helper/OutputHelper.php +++ b/src/Helper/OutputHelper.php @@ -197,7 +197,7 @@ 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); @@ -205,8 +205,13 @@ protected function showHelp(string $for, array $items, string $header = '', stri } $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) { diff --git a/src/IO/Interactor.php b/src/IO/Interactor.php index a36747b..9112383 100644 --- a/src/IO/Interactor.php +++ b/src/IO/Interactor.php @@ -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) diff --git a/src/Output/Color.php b/src/Output/Color.php index c2fceb2..e53ee69 100644 --- a/src/Output/Color.php +++ b/src/Output/Color.php @@ -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], ]; /** diff --git a/src/Output/Writer.php b/src/Output/Writer.php index 9528c12..ca1cff9 100644 --- a/src/Output/Writer.php +++ b/src/Output/Writer.php @@ -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)