diff --git a/src/Color.php b/src/Color.php index 3df2570..774aec6 100644 --- a/src/Color.php +++ b/src/Color.php @@ -135,11 +135,12 @@ class Color * @param string $string * @param ?int $fg * @param ?int $bg + * @param bool $raw * @return string */ - public static function colorize(string $string, ?int $fg = null, ?int $bg = null): string + public static function colorize(string $string, ?int $fg = null, ?int $bg = null, bool $raw = false): string { - if (stripos(PHP_OS, 'win') === false) { + if ((stripos(PHP_OS, 'win') === false) && (!$raw)) { return static::getFgColorCode($fg) . static::getBgColorCode($bg) . $string . "\x1b[0m"; } else { return $string; diff --git a/src/Console.php b/src/Console.php index 88eb99d..8e873d6 100644 --- a/src/Console.php +++ b/src/Console.php @@ -576,14 +576,15 @@ public function addCommandsFromRoutes(Cli $routeMatch, ?string $scriptName = nul * Get a help * * @param ?string $command + * @param bool $raw * @return string|null */ - public function help(?string $command = null): string|null + public function help(?string $command = null, bool $raw = false): string|null { if ($command !== null) { return $this->commands[$command]?->getHelp(); } else { - $this->displayHelp(); + $this->displayHelp($raw); return null; } } @@ -1183,7 +1184,7 @@ public function send(bool $withHeaders = true): Console * * @return void */ - public function displayHelp(): void + public function displayHelp(bool $raw = false): void { $this->response = null; $commands = []; @@ -1203,14 +1204,14 @@ public function displayHelp(): void $name1 = substr($name, 0, strpos($name, ' ')); $name2 = substr($name, strpos($name, ' ') + 1); if (isset($this->helpColors[0])) { - $name1 = Color::colorize($name1, $this->helpColors[0]); + $name1 = Color::colorize($name1, $this->helpColors[0], null, $raw); } if (isset($this->helpColors[1])) { - $name2 = Color::colorize($name2, $this->helpColors[1]); + $name2 = Color::colorize($name2, $this->helpColors[1], null, $raw); } $name = $name1 . ' ' . $name2; } else if (isset($this->helpColors[0])){ - $name = Color::colorize($name, $this->helpColors[0]); + $name = Color::colorize($name, $this->helpColors[0], null, $raw); } } @@ -1227,12 +1228,12 @@ public function displayHelp(): void $colorIndex = 3; } $name .= ' ' . ((isset($this->helpColors[$colorIndex])) ? - Color::colorize($p, $this->helpColors[$colorIndex]) : $p); + Color::colorize($p, $this->helpColors[$colorIndex], null, $raw) : $p); } } } else { $name .= ' ' . ((isset($this->helpColors[2])) ? - Color::colorize($params, $this->helpColors[2]) : $params); + Color::colorize($params, $this->helpColors[2], null, $raw) : $params); } }