Skip to content

Commit 5ece2b8

Browse files
committed
Added color styling to CLI doctor and help
1 parent 8c8f9fe commit 5ece2b8

1 file changed

Lines changed: 24 additions & 22 deletions

File tree

src/QuickInstall/Sandbox/Application.php

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -431,11 +431,13 @@ private function doctor(): int
431431
{
432432
$checks = (new DoctorService($this->project))->checks();
433433
$failed = false;
434-
echo "QuickInstall requirements\n";
434+
echo $this->style('QuickInstall requirements', '1') . "\n";
435435
foreach ($checks as $check)
436436
{
437-
$status = $check['ok'] ? 'OK' : 'FAIL';
438-
echo "[$status] {$check['name']}: {$check['detail']}\n";
437+
$status = $check['ok']
438+
? $this->style('[OK]', '1;32')
439+
: $this->style('[FAIL]', '1;31');
440+
echo "$status {$check['name']}: {$check['detail']}\n";
439441
$failed = $failed || !$check['ok'];
440442
}
441443

@@ -469,7 +471,7 @@ private function supportsAnsi(): bool
469471
}
470472
if (PHP_OS_FAMILY === 'Windows' && function_exists('sapi_windows_vt100_support') && defined('STDOUT'))
471473
{
472-
return sapi_windows_vt100_support(STDOUT);
474+
return sapi_windows_vt100_support(STDOUT, true);
473475
}
474476

475477
return PHP_SAPI === 'cli';
@@ -874,22 +876,22 @@ private function help(array $args = []): void
874876
return;
875877
}
876878

877-
echo "QuickInstall CLI\n";
879+
echo $this->style('QuickInstall CLI', '1') . "\n";
878880
echo "Create disposable local phpBB boards with Docker.\n\n";
879-
echo "Usage:\n";
880-
echo " qi <command> [arguments] [options]\n";
881-
echo " qi help [command]\n\n";
882-
echo "Common workflow:\n";
883-
echo " qi board:create demo --phpbb 3.3 --db mariadb --port 8081 --populate extension-dev\n";
884-
echo " qi board:start demo\n\n";
881+
echo $this->style('Usage:', '1;33') . "\n";
882+
echo ' ' . $this->style('qi <command> [arguments] [options]', '1;36') . "\n";
883+
echo ' ' . $this->style('qi help [command]', '1;36') . "\n\n";
884+
echo $this->style('Common workflow:', '1;33') . "\n";
885+
echo ' ' . $this->style('qi board:create demo --phpbb 3.3 --db mariadb --port 8081 --populate extension-dev', '1;36') . "\n";
886+
echo ' ' . $this->style('qi board:start demo', '1;36') . "\n\n";
885887

886888
foreach ($commands as $group => $items)
887889
{
888-
echo "$group:\n";
890+
echo $this->style("$group:", '1;33') . "\n";
889891
$width = max(array_map('strlen', array_keys($items)));
890892
foreach ($items as $name => $help)
891893
{
892-
echo ' ' . str_pad($name, $width) . ' ' . $help['summary'] . "\n";
894+
echo ' ' . $this->style(str_pad($name, $width), '1;36') . ' ' . $help['summary'] . "\n";
893895
}
894896
echo "\n";
895897
}
@@ -908,27 +910,27 @@ private function helpCommand(string $command, array $groups): void
908910
}
909911

910912
$help = $items[$command];
911-
echo "{$help['title']}\n\n";
912-
echo "Usage:\n";
913-
echo " qi {$help['usage']}\n\n";
914-
echo "Description:\n";
913+
echo $this->style($help['title'], '1') . "\n\n";
914+
echo $this->style('Usage:', '1;33') . "\n";
915+
echo ' ' . $this->style("qi {$help['usage']}", '1;36') . "\n\n";
916+
echo $this->style('Description:', '1;33') . "\n";
915917
echo " {$help['description']}\n";
916918
if (!empty($help['arguments']))
917919
{
918-
echo "\nArguments:\n";
920+
echo "\n" . $this->style('Arguments:', '1;33') . "\n";
919921
$this->printHelpRows($help['arguments']);
920922
}
921923
if (!empty($help['options']))
922924
{
923-
echo "\nOptions:\n";
925+
echo "\n" . $this->style('Options:', '1;33') . "\n";
924926
$this->printHelpRows($help['options']);
925927
}
926928
if (!empty($help['examples']))
927929
{
928-
echo "\nExamples:\n";
930+
echo "\n" . $this->style('Examples:', '1;33') . "\n";
929931
foreach ($help['examples'] as $example)
930932
{
931-
echo " qi $example\n";
933+
echo ' ' . $this->style("qi $example", '1;36') . "\n";
932934
}
933935
}
934936
echo "\n";
@@ -944,7 +946,7 @@ private function printHelpRows(array $rows): void
944946
$width = max(array_map('strlen', array_keys($rows)));
945947
foreach ($rows as $name => $description)
946948
{
947-
echo ' ' . str_pad($name, $width) . ' ' . $description . "\n";
949+
echo ' ' . $this->style(str_pad($name, $width), '1;36') . ' ' . $description . "\n";
948950
}
949951
}
950952

0 commit comments

Comments
 (0)