in java/io/bazel/rules/closure/webfiles/WebfilesValidatorProgram.java [82:140]
private int run(Iterable<String> args) throws IOException {
Webfiles target = null;
List<Webfiles> directDeps = new ArrayList<>();
final List<Path> transitiveDeps = new ArrayList<>();
Iterator<String> flags = args.iterator();
Set<String> suppress = new HashSet<>();
while (flags.hasNext()) {
String flag = flags.next();
switch (flag) {
case "--dummy":
Files.write(fs.getPath(flags.next()), new byte[0]);
break;
case "--target":
target = loadWebfilesPbtxt(fs.getPath(flags.next()));
break;
case "--direct_dep":
directDeps.add(loadWebfilesPbtxt(fs.getPath(flags.next())));
break;
case "--transitive_dep":
transitiveDeps.add(fs.getPath(flags.next()));
break;
case "--suppress":
suppress.add(flags.next());
break;
default:
throw new RuntimeException("Unexpected flag: " + flag);
}
}
if (target == null) {
output.println(ERROR_PREFIX + "Missing --target flag");
return 1;
}
Multimap<String, String> errors =
validator.validate(
target,
directDeps,
Suppliers.memoize(
new Supplier<ImmutableList<Webfiles>>() {
@Override
public ImmutableList<Webfiles> get() {
ImmutableList.Builder<Webfiles> builder = new ImmutableList.Builder<>();
for (Path path : transitiveDeps) {
try {
builder.add(loadWebfilesPbtxt(path));
} catch (IOException e) {
throw new RuntimeException(e);
}
}
return builder.build();
}
}));
Set<String> superfluous =
Sets.difference(suppress, Sets.union(errors.keySet(), NEVER_SUPERFLUOUS));
if (!superfluous.isEmpty()) {
errors.put(
SUPERFLUOUS_SUPPRESS_ERROR, "Superfluous suppress codes: " + joinWords(superfluous));
}
return displayErrors(suppress, errors);
}