diff --git a/CodeSniffer/CLI.php b/CodeSniffer/CLI.php index 22858842c7..538c8c4a26 100644 --- a/CodeSniffer/CLI.php +++ b/CodeSniffer/CLI.php @@ -600,6 +600,17 @@ public function processLongArgument($arg, $pos) } $this->values['sniffs'] = $sniffs; + } else if (substr($arg, 0, 10) === 'bootstrap=') { + $files = explode(',', substr($arg, 10)); + foreach ($files as $file) { + if (file_exists($file) === false) { + echo 'ERROR: The specified bootstrap file "'.$file.'" does not exist'.PHP_EOL.PHP_EOL; + $this->printUsage(); + exit(2); + } + } + + $this->values['bootstrap'] = $files; } else if (substr($arg, 0, 12) === 'report-file=') { $this->values['reportFile'] = PHP_CodeSniffer::realpath(substr($arg, 12)); @@ -780,6 +791,12 @@ public function process($values=array()) $this->values = $values; } + if (empty($values['bootstrap']) === false) { + foreach ($values['bootstrap'] as $bootstrap) { + include $bootstrap; + } + } + if ($values['generator'] !== '') { $phpcs = new PHP_CodeSniffer($values['verbosity']); if ($values['standard'] === null) { @@ -1154,7 +1171,8 @@ public function printPHPCSUsage() echo ' [--severity=] [--error-severity=] [--warning-severity=]'.PHP_EOL; echo ' [--runtime-set key value] [--config-set key value] [--config-delete key] [--config-show]'.PHP_EOL; echo ' [--standard=] [--sniffs=] [--encoding=]'.PHP_EOL; - echo ' [--extensions=] [--ignore=] ...'.PHP_EOL; + echo ' [--extensions=] [--ignore=]'.PHP_EOL; + echo ' [--bootstrap=] ...'.PHP_EOL; echo ' Set runtime value (see --config-set) '.PHP_EOL; echo ' -n Do not print warnings (shortcut for --warning-severity=0)'.PHP_EOL; echo ' -w Print both warnings and errors (this is the default)'.PHP_EOL; @@ -1171,6 +1189,7 @@ public function printPHPCSUsage() echo ' --colors Use colors in output'.PHP_EOL; echo ' --no-colors Do not use colors in output (this is the default)'.PHP_EOL; echo ' One or more files and/or directories to check'.PHP_EOL; + echo ' A file to run before processing sniffs'.PHP_EOL; echo ' The encoding of the files being checked (default is iso-8859-1)'.PHP_EOL; echo ' A comma separated list of file extensions to check'.PHP_EOL; echo ' (extension filtering only valid when checking a directory)'.PHP_EOL; @@ -1206,7 +1225,8 @@ public function printPHPCBFUsage() echo ' [--standard=] [--sniffs=] [--suffix=]'.PHP_EOL; echo ' [--severity=] [--error-severity=] [--warning-severity=]'.PHP_EOL; echo ' [--tab-width=] [--encoding=]'.PHP_EOL; - echo ' [--extensions=] [--ignore=] ...'.PHP_EOL; + echo ' [--extensions=] [--ignore=]'.PHP_EOL; + echo ' [--bootstrap=] ...'.PHP_EOL; echo ' -n Do not fix warnings (shortcut for --warning-severity=0)'.PHP_EOL; echo ' -w Fix both warnings and errors (on by default)'.PHP_EOL; echo ' -l Local directory only, no recursion'.PHP_EOL; @@ -1216,6 +1236,7 @@ public function printPHPCBFUsage() echo ' --version Print version information'.PHP_EOL; echo ' --no-patch Do not make use of the "diff" or "patch" programs'.PHP_EOL; echo ' One or more files and/or directories to fix'.PHP_EOL; + echo ' A file to run before processing sniffs'.PHP_EOL; echo ' The encoding of the files being fixed (default is iso-8859-1)'.PHP_EOL; echo ' A comma separated list of file extensions to fix'.PHP_EOL; echo ' (extension filtering only valid when checking a directory)'.PHP_EOL;