1717use PHP_CodeSniffer \Exceptions \DeepExitException ;
1818use PHP_CodeSniffer \Exceptions \RuntimeException ;
1919use PHP_CodeSniffer \Util \Common ;
20+ use PHP_CodeSniffer \Util \Help ;
2021use PHP_CodeSniffer \Util \Standards ;
2122
2223/**
@@ -1395,71 +1396,21 @@ public function printShortUsage($return=false)
13951396 */
13961397 public function printPHPCSUsage ()
13971398 {
1398- echo 'Usage: phpcs [-nwlsaepqvi] [-d key[=value]] [--colors] [--no-colors] ' .PHP_EOL ;
1399- echo ' [--cache[=<cacheFile>]] [--no-cache] [--tab-width=<tabWidth>] ' .PHP_EOL ;
1400- echo ' [--report=<report>] [--report-file=<reportFile>] [--report-<report>=<reportFile>] ' .PHP_EOL ;
1401- echo ' [--report-width=<reportWidth>] [--basepath=<basepath>] [--bootstrap=<bootstrap>] ' .PHP_EOL ;
1402- echo ' [--severity=<severity>] [--error-severity=<severity>] [--warning-severity=<severity>] ' .PHP_EOL ;
1403- echo ' [--runtime-set key value] [--config-set key value] [--config-delete key] [--config-show] ' .PHP_EOL ;
1404- echo ' [--standard=<standard>] [--sniffs=<sniffs>] [--exclude=<sniffs>] ' .PHP_EOL ;
1405- echo ' [--encoding=<encoding>] [--parallel=<processes>] [--generator=<generator>] ' .PHP_EOL ;
1406- echo ' [--extensions=<extensions>] [--ignore=<patterns>] [--ignore-annotations] ' .PHP_EOL ;
1407- echo ' [--stdin-path=<stdinPath>] [--file-list=<fileList>] [--filter=<filter>] <file> - ... ' .PHP_EOL ;
1408- echo PHP_EOL ;
1409- echo ' - Check STDIN instead of local files and directories ' .PHP_EOL ;
1410- echo ' -n Do not print warnings (shortcut for --warning-severity=0) ' .PHP_EOL ;
1411- echo ' -w Print both warnings and errors (this is the default) ' .PHP_EOL ;
1412- echo ' -l Local directory only, no recursion ' .PHP_EOL ;
1413- echo ' -s Show error codes in all reports ' .PHP_EOL ;
1414- echo ' -a Run interactively ' .PHP_EOL ;
1415- echo ' -e Explain a standard by showing the sniffs it includes ' .PHP_EOL ;
1416- echo ' -p Show progress of the run ' .PHP_EOL ;
1417- echo ' -q Quiet mode; disables progress and verbose output ' .PHP_EOL ;
1418- echo ' -m Stop error messages from being recorded ' .PHP_EOL ;
1419- echo ' (saves a lot of memory, but stops many reports from being used) ' .PHP_EOL ;
1420- echo ' -v Print processed files ' .PHP_EOL ;
1421- echo ' -vv Print ruleset and token output ' .PHP_EOL ;
1422- echo ' -vvv Print sniff processing information ' .PHP_EOL ;
1423- echo ' -i Show a list of installed coding standards ' .PHP_EOL ;
1424- echo ' -d Set the [key] php.ini value to [value] or [true] if value is omitted ' .PHP_EOL ;
1425- echo PHP_EOL ;
1426- echo ' --help Print this help message ' .PHP_EOL ;
1427- echo ' --version Print version information ' .PHP_EOL ;
1428- echo ' --colors Use colors in output ' .PHP_EOL ;
1429- echo ' --no-colors Do not use colors in output (this is the default) ' .PHP_EOL ;
1430- echo ' --cache Cache results between runs ' .PHP_EOL ;
1431- echo ' --no-cache Do not cache results between runs (this is the default) ' .PHP_EOL ;
1432- echo ' --ignore-annotations Ignore all phpcs: annotations in code comments ' .PHP_EOL ;
1433- echo PHP_EOL ;
1434- echo ' <cacheFile> Use a specific file for caching (uses a temporary file by default) ' .PHP_EOL ;
1435- echo ' <basepath> A path to strip from the front of file paths inside reports ' .PHP_EOL ;
1436- echo ' <bootstrap> A comma separated list of files to run before processing begins ' .PHP_EOL ;
1437- echo ' <encoding> The encoding of the files being checked (default is utf-8) ' .PHP_EOL ;
1438- echo ' <extensions> A comma separated list of file extensions to check ' .PHP_EOL ;
1439- echo ' The type of the file can be specified using: ext/type ' .PHP_EOL ;
1440- echo ' e.g., module/php,es/js ' .PHP_EOL ;
1441- echo ' <file> One or more files and/or directories to check ' .PHP_EOL ;
1442- echo ' <fileList> A file containing a list of files and/or directories to check (one per line) ' .PHP_EOL ;
1443- echo ' <filter> Use either the "GitModified" or "GitStaged" filter, ' .PHP_EOL ;
1444- echo ' or specify the path to a custom filter class ' .PHP_EOL ;
1445- echo ' <generator> Use either the "HTML", "Markdown" or "Text" generator ' .PHP_EOL ;
1446- echo ' (forces documentation generation instead of checking) ' .PHP_EOL ;
1447- echo ' <patterns> A comma separated list of patterns to ignore files and directories ' .PHP_EOL ;
1448- echo ' <processes> How many files should be checked simultaneously (default is 1) ' .PHP_EOL ;
1449- echo ' <report> Print either the "full", "xml", "checkstyle", "csv" ' .PHP_EOL ;
1450- echo ' "json", "junit", "emacs", "source", "summary", "diff" ' .PHP_EOL ;
1451- echo ' "svnblame", "gitblame", "hgblame", "notifysend" or "performance", ' .PHP_EOL ;
1452- echo ' report or specify the path to a custom report class ' .PHP_EOL ;
1453- echo ' (the "full" report is printed by default) ' .PHP_EOL ;
1454- echo ' <reportFile> Write the report to the specified file path ' .PHP_EOL ;
1455- echo ' <reportWidth> How many columns wide screen reports should be printed ' .PHP_EOL ;
1456- echo ' or set to "auto" to use current screen width, where supported ' .PHP_EOL ;
1457- echo ' <severity> The minimum severity required to display an error or warning ' .PHP_EOL ;
1458- echo ' <sniffs> A comma separated list of sniff codes to include or exclude from checking ' .PHP_EOL ;
1459- echo ' (all sniffs must be part of the specified standard) ' .PHP_EOL ;
1460- echo ' <standard> The name or path of the coding standard to use ' .PHP_EOL ;
1461- echo ' <stdinPath> If processing STDIN, the file path that STDIN will be processed as ' .PHP_EOL ;
1462- echo ' <tabWidth> The number of spaces each tab represents ' .PHP_EOL ;
1399+ $ longOptions = explode (', ' , Help::DEFAULT_LONG_OPTIONS );
1400+ $ longOptions [] = 'cache ' ;
1401+ $ longOptions [] = 'no-cache ' ;
1402+ $ longOptions [] = 'report ' ;
1403+ $ longOptions [] = 'report-file ' ;
1404+ $ longOptions [] = 'report-report ' ;
1405+ $ longOptions [] = 'config-explain ' ;
1406+ $ longOptions [] = 'config-set ' ;
1407+ $ longOptions [] = 'config-delete ' ;
1408+ $ longOptions [] = 'config-show ' ;
1409+ $ longOptions [] = 'generator ' ;
1410+
1411+ $ shortOptions = Help::DEFAULT_SHORT_OPTIONS .'aems ' ;
1412+
1413+ (new Help ($ this , $ longOptions , $ shortOptions ))->display ();
14631414
14641415 }//end printPHPCSUsage()
14651416
@@ -1471,49 +1422,11 @@ public function printPHPCSUsage()
14711422 */
14721423 public function printPHPCBFUsage ()
14731424 {
1474- echo 'Usage: phpcbf [-nwli] [-d key[=value]] [--ignore-annotations] [--bootstrap=<bootstrap>] ' .PHP_EOL ;
1475- echo ' [--standard=<standard>] [--sniffs=<sniffs>] [--exclude=<sniffs>] [--suffix=<suffix>] ' .PHP_EOL ;
1476- echo ' [--severity=<severity>] [--error-severity=<severity>] [--warning-severity=<severity>] ' .PHP_EOL ;
1477- echo ' [--tab-width=<tabWidth>] [--encoding=<encoding>] [--parallel=<processes>] ' .PHP_EOL ;
1478- echo ' [--basepath=<basepath>] [--extensions=<extensions>] [--ignore=<patterns>] ' .PHP_EOL ;
1479- echo ' [--stdin-path=<stdinPath>] [--file-list=<fileList>] [--filter=<filter>] <file> - ... ' .PHP_EOL ;
1480- echo PHP_EOL ;
1481- echo ' - Fix STDIN instead of local files and directories ' .PHP_EOL ;
1482- echo ' -n Do not fix warnings (shortcut for --warning-severity=0) ' .PHP_EOL ;
1483- echo ' -w Fix both warnings and errors (on by default) ' .PHP_EOL ;
1484- echo ' -l Local directory only, no recursion ' .PHP_EOL ;
1485- echo ' -p Show progress of the run ' .PHP_EOL ;
1486- echo ' -q Quiet mode; disables progress and verbose output ' .PHP_EOL ;
1487- echo ' -v Print processed files ' .PHP_EOL ;
1488- echo ' -vv Print ruleset and token output ' .PHP_EOL ;
1489- echo ' -vvv Print sniff processing information ' .PHP_EOL ;
1490- echo ' -i Show a list of installed coding standards ' .PHP_EOL ;
1491- echo ' -d Set the [key] php.ini value to [value] or [true] if value is omitted ' .PHP_EOL ;
1492- echo PHP_EOL ;
1493- echo ' --help Print this help message ' .PHP_EOL ;
1494- echo ' --version Print version information ' .PHP_EOL ;
1495- echo ' --ignore-annotations Ignore all phpcs: annotations in code comments ' .PHP_EOL ;
1496- echo PHP_EOL ;
1497- echo ' <basepath> A path to strip from the front of file paths inside reports ' .PHP_EOL ;
1498- echo ' <bootstrap> A comma separated list of files to run before processing begins ' .PHP_EOL ;
1499- echo ' <encoding> The encoding of the files being fixed (default is utf-8) ' .PHP_EOL ;
1500- echo ' <extensions> A comma separated list of file extensions to fix ' .PHP_EOL ;
1501- echo ' The type of the file can be specified using: ext/type ' .PHP_EOL ;
1502- echo ' e.g., module/php,es/js ' .PHP_EOL ;
1503- echo ' <file> One or more files and/or directories to fix ' .PHP_EOL ;
1504- echo ' <fileList> A file containing a list of files and/or directories to fix (one per line) ' .PHP_EOL ;
1505- echo ' <filter> Use either the "GitModified" or "GitStaged" filter, ' .PHP_EOL ;
1506- echo ' or specify the path to a custom filter class ' .PHP_EOL ;
1507- echo ' <patterns> A comma separated list of patterns to ignore files and directories ' .PHP_EOL ;
1508- echo ' <processes> How many files should be fixed simultaneously (default is 1) ' .PHP_EOL ;
1509- echo ' <severity> The minimum severity required to fix an error or warning ' .PHP_EOL ;
1510- echo ' <sniffs> A comma separated list of sniff codes to include or exclude from fixing ' .PHP_EOL ;
1511- echo ' (all sniffs must be part of the specified standard) ' .PHP_EOL ;
1512- echo ' <standard> The name or path of the coding standard to use ' .PHP_EOL ;
1513- echo ' <stdinPath> If processing STDIN, the file path that STDIN will be processed as ' .PHP_EOL ;
1514- echo ' <suffix> Write modified files to a filename using this suffix ' .PHP_EOL ;
1515- echo ' ("diff" and "patch" are not used in this mode) ' .PHP_EOL ;
1516- echo ' <tabWidth> The number of spaces each tab represents ' .PHP_EOL ;
1425+ $ longOptions = explode (', ' , Help::DEFAULT_LONG_OPTIONS );
1426+ $ longOptions [] = 'suffix ' ;
1427+ $ shortOptions = Help::DEFAULT_SHORT_OPTIONS ;
1428+
1429+ (new Help ($ this , $ longOptions , $ shortOptions ))->display ();
15171430
15181431 }//end printPHPCBFUsage()
15191432
0 commit comments