Skip to content

Commit

Permalink
Add bootstrap file option
Browse files Browse the repository at this point in the history
  • Loading branch information
johnmaguire committed Nov 26, 2015
1 parent e955837 commit c385bd8
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions CodeSniffer/CLI.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));

Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -1154,7 +1171,8 @@ public function printPHPCSUsage()
echo ' [--severity=<severity>] [--error-severity=<severity>] [--warning-severity=<severity>]'.PHP_EOL;
echo ' [--runtime-set key value] [--config-set key value] [--config-delete key] [--config-show]'.PHP_EOL;
echo ' [--standard=<standard>] [--sniffs=<sniffs>] [--encoding=<encoding>]'.PHP_EOL;
echo ' [--extensions=<extensions>] [--ignore=<patterns>] <file> ...'.PHP_EOL;
echo ' [--extensions=<extensions>] [--ignore=<patterns>]'.PHP_EOL;
echo ' [--bootstrap=<bootstrap>] <file> ...'.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;
Expand All @@ -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 ' <file> One or more files and/or directories to check'.PHP_EOL;
echo ' <bootstrap> A file to run before processing sniffs'.PHP_EOL;
echo ' <encoding> The encoding of the files being checked (default is iso-8859-1)'.PHP_EOL;
echo ' <extensions> A comma separated list of file extensions to check'.PHP_EOL;
echo ' (extension filtering only valid when checking a directory)'.PHP_EOL;
Expand Down Expand Up @@ -1206,7 +1225,8 @@ public function printPHPCBFUsage()
echo ' [--standard=<standard>] [--sniffs=<sniffs>] [--suffix=<suffix>]'.PHP_EOL;
echo ' [--severity=<severity>] [--error-severity=<severity>] [--warning-severity=<severity>]'.PHP_EOL;
echo ' [--tab-width=<tabWidth>] [--encoding=<encoding>]'.PHP_EOL;
echo ' [--extensions=<extensions>] [--ignore=<patterns>] <file> ...'.PHP_EOL;
echo ' [--extensions=<extensions>] [--ignore=<patterns>]'.PHP_EOL;
echo ' [--bootstrap=<bootstrap>] <file> ...'.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;
Expand All @@ -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 ' <file> One or more files and/or directories to fix'.PHP_EOL;
echo ' <bootstrap> A file to run before processing sniffs'.PHP_EOL;
echo ' <encoding> The encoding of the files being fixed (default is iso-8859-1)'.PHP_EOL;
echo ' <extensions> A comma separated list of file extensions to fix'.PHP_EOL;
echo ' (extension filtering only valid when checking a directory)'.PHP_EOL;
Expand Down

0 comments on commit c385bd8

Please sign in to comment.