Improves help command

This commit is contained in:
Nuno Maduro
2022-09-18 11:10:18 +01:00
parent 0e0e2adfbe
commit 4de7284657
3 changed files with 21 additions and 9 deletions

View File

@ -1,4 +1,4 @@
<div class="mx-2">
<span class="text-blue font-bold">USAGE:</span><span class="ml-1">pest</span><span class="ml-1 text-gray"><?php echo htmlspecialchars('<file>') ?> [options]</span>
<span class="text-yellow font-bold">USAGE:</span><span class="ml-1">pest</span><span class="ml-1 text-gray"><?php echo htmlspecialchars('<file>') ?> [options]</span>
</div>

View File

@ -45,7 +45,7 @@ final class Help implements HandlesArguments
$this->output->writeln([
'',
sprintf(' <fg=blue;options=bold>%s:</>', mb_strtoupper($title)),
sprintf(' <fg=yellow;options=bold>%s OPTIONS:</>', mb_strtoupper($title)),
]);
foreach ($options as $option) {
@ -58,6 +58,8 @@ final class Help implements HandlesArguments
'desc' => $description,
] = $option;
$argument = $this->colorizeOptions($argument);
View::render('components.two-column-detail', [
'left' => $argument,
'right' => $description,
@ -73,6 +75,16 @@ final class Help implements HandlesArguments
return $arguments;
}
/**
* Colorizes the given string options.
*/
private function colorizeOptions(string $argument): string
{
$argument = (string) preg_replace('/(--\w+)/', '<fg=blue;options=bold>$1</>', $argument);
return (string) preg_replace('/(-\w+)/', '<fg=blue;options=bold>$1</>', $argument);
}
/**
* @return array<string, array<int, array{arg?: string, desc: string}>>
*/

View File

@ -3,7 +3,7 @@
USAGE: pest <file> [options]
CONFIGURATION:
CONFIGURATION OPTIONS:
--init ............................ Initialise a standard Pest configuration
-c|--configuration <file> ....................... Read configuration from XML file
--no-configuration ......... Ignore default configuration file (phpunit.xml)
@ -14,7 +14,7 @@
--generate-configuration Generate configuration file with suggested settings
--migrate-configuration ....... Migrate configuration file to current format
SELECTION:
SELECTION OPTIONS:
--list-suites ................................... List available test suites
--testsuite <name> ............... Only run tests from the specified test suite(s)
--exclude-testsuite <name> ........ Exclude tests from the specified test suite(s)
@ -28,7 +28,7 @@
--filter <pattern> ........................................ Filter which tests to run
--test-suffix <suffixes> Only search for test in files with specified suffix(es). Default: Test.php,.phpt
EXECUTION:
EXECUTION OPTIONS:
--process-isolation ................ Run each test in a separate PHP process
--globals-backup ................. Backup and restore $GLOBALS for each test
--static-backup ......... Backup and restore static properties for each test
@ -55,7 +55,7 @@
--order-by <order> Run tests in order: default|defects|duration|no-depends|random|reverse|size
--random-order-seed <N> .......... Use a specific random seed <N> for random order
REPORTING:
REPORTING OPTIONS:
--colors <flag> ............... Use colors in output ("never", "auto" or "always")
--columns <n> .................... Number of columns to use for progress output
--columns max ............ Use maximum number of columns for progress output
@ -71,7 +71,7 @@
--testdox ................. Report test execution progress in TestDox format
--no-interaction ........................ Disable TestDox progress animation
LOGGING:
LOGGING OPTIONS:
--log-junit <file> ................ Log test execution in JUnit XML format to file
--log-teamcity <file> .............. Log test execution in TeamCity format to file
--testdox-html <file> ........... Write agile documentation in HTML format to file
@ -81,7 +81,7 @@
--log-events-verbose-text <file> Stream events as plain text to file (with telemetry information)
--no-logging .................................. Ignore logging configuration
CODE COVERAGE:
CODE COVERAGE OPTIONS:
--coverage ..... Generate code coverage report and output to standard output
--coverage --min Set the minimum required coverage percentage, and fail if not met
--coverage-crap4j <file> ...... Generate code coverage report in Crap4J XML format
@ -95,7 +95,7 @@
--disable-coverage-ignore Disable attributes and annotations for ignoring code coverage
--no-coverage ........................... Ignore code coverage configuration
MISCELLANEOUS:
MISCELLANEOUS OPTIONS:
-h|--help .................................... Prints this usage information
--version ..................................... Prints the version and exits
--atleast-version <min> ....... Checks that version is greater than min and exits