Skip to content

Commit 6033ce9

Browse files
authored
Reject invalid onlyIssues CLI usage (#239)
1 parent 1c107cd commit 6033ce9

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

lib/cmd_line.dart

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ ValidationOptions _getValidationOptionsFromYaml(String fileName) {
9090
const kOverride = 'override';
9191

9292
void abort(Object e) {
93-
stderr.write(e);
93+
stderr.writeln(e);
9494
exit(kErrorCode);
9595
}
9696

@@ -135,7 +135,7 @@ ValidationOptions _getValidationOptionsFromYaml(String fileName) {
135135
}
136136
}, growable: false);
137137
} else if (yamlIgnoredIssues != null) {
138-
abort("$kYamlError 'ignored' must be a sequence.");
138+
abort("$kYamlError '$kIgnore' must be a sequence.");
139139
}
140140

141141
final Object yamlOnlyIssues = yaml[kOnly];
@@ -150,7 +150,12 @@ ValidationOptions _getValidationOptionsFromYaml(String fileName) {
150150
}
151151
}, growable: false);
152152
} else if (yamlOnlyIssues != null) {
153-
abort("$kYamlError 'only' must be a sequence.");
153+
abort("$kYamlError '$kOnly' must be a sequence.");
154+
}
155+
156+
if (onlyIssues != null && ignoredIssues != null) {
157+
abort("$kYamlError option '$kOnly' cannot be used "
158+
"along with option '$kIgnore'.");
154159
}
155160

156161
final Object yamlSeveritiesMap = yaml[kOverride];

node/gltf_validator.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,8 +229,8 @@ Context _getContextFromOptions(_JSValidationOptions options) {
229229
}
230230

231231
if (options.onlyIssues != null && options.ignoredIssues != null) {
232-
throw ArgumentError(
233-
'options.onlyIssues cannot be used along with options.ignoredIssues.');
232+
throw ArgumentError('options.onlyIssues cannot be used '
233+
'along with options.ignoredIssues.');
234234
}
235235

236236
if (options.onlyIssues != null) {

0 commit comments

Comments
 (0)