Skip to content

Commit 3f6105f

Browse files
authored
i add max-counts
1 parent a3d11dd commit 3f6105f

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

run.php

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ function usage() {
3434

3535
"--lang" =>
3636
"[Optional] Language file to use for the result (en-us by default).",
37+
38+
"--max-errors" =>
39+
"[Optional] Defines how many errors are still allowed for a pass (0 by default)",
3740

3841
"--level" =>
3942
"[Optional] Specifies the output level (info, warning, error). For console report only.",
@@ -68,6 +71,7 @@ function usage() {
6871
$options['lang'] = 'en-us';
6972
$options['quiet'] = false;
7073
$options['time'] = false;
74+
$options['max-errors'] = 0;
7175
$lineCountFile = null;
7276

7377
// loop through user input
@@ -98,10 +102,10 @@ function usage() {
98102
$options['lang'] = $_SERVER['argv'][$i];
99103
break;
100104

101-
case "--level":
102-
$i++;
103-
$options['level'] = $_SERVER['argv'][$i];
104-
break;
105+
case "--level":
106+
$i++;
107+
$options['level'] = $_SERVER['argv'][$i];
108+
break;
105109

106110
case "--config":
107111
$i++;
@@ -167,6 +171,10 @@ function usage() {
167171
echo "\nPlease specify a source directory/file using --src option.\n\n";
168172
usage();
169173
}
174+
if (!$options['max-errors']) {
175+
echo "\nPlease specify a number when using --max-errors option.\n\n";
176+
usage();
177+
}
170178

171179
if (!empty($options['linecount'])) {
172180
$lineCountFile = "ncss.xml";
@@ -222,8 +230,5 @@ function usage() {
222230

223231
}
224232

225-
226-
227-
228-
$exitCode = ($errorCounts[ERROR] > 0) ? 1 : 0;
233+
$exitCode = ($errorCounts[ERROR] > $options['max-errors']) ? 1 : 0;
229234
exit($exitCode);

0 commit comments

Comments
 (0)