set exit code to number of errors

This commit is contained in:
Grahame Grieve 2019-08-14 17:34:07 +10:00
parent 2a234a81c2
commit 75d86a15ee
1 changed files with 6 additions and 3 deletions

View File

@ -454,17 +454,19 @@ public class Validator {
System.out.println(" .. validate "+sources); System.out.println(" .. validate "+sources);
validator.prepare(); // generate any missing snapshots validator.prepare(); // generate any missing snapshots
Resource r = validator.validate(sources, profiles); Resource r = validator.validate(sources, profiles);
int ec = 0;
if (output == null) { if (output == null) {
if (r instanceof Bundle) if (r instanceof Bundle)
for (BundleEntryComponent e : ((Bundle)r).getEntry()) for (BundleEntryComponent e : ((Bundle)r).getEntry())
displayOO((OperationOutcome)e.getResource()); ec = displayOO((OperationOutcome)e.getResource()) + ec;
else else
displayOO((OperationOutcome)r); ec = displayOO((OperationOutcome)r);
} else { } else {
FileOutputStream s = new FileOutputStream(output); FileOutputStream s = new FileOutputStream(output);
x.compose(s, r); x.compose(s, r);
s.close(); s.close();
} }
System.exit(ec);
} }
} }
} }
@ -512,7 +514,7 @@ public class Validator {
s.close(); s.close();
} }
private static void displayOO(OperationOutcome oo) { private static int displayOO(OperationOutcome oo) {
int error = 0; int error = 0;
int warn = 0; int warn = 0;
int info = 0; int info = 0;
@ -532,6 +534,7 @@ public class Validator {
System.out.println(getIssueSummary(issue)); System.out.println(getIssueSummary(issue));
} }
System.out.println(); System.out.println();
return error;
} }
private static String getIssueSummary(OperationOutcomeIssueComponent issue) { private static String getIssueSummary(OperationOutcomeIssueComponent issue) {