From 75d86a15ee1212d59d6398dce27380a6ffecadf8 Mon Sep 17 00:00:00 2001 From: Grahame Grieve Date: Wed, 14 Aug 2019 17:34:07 +1000 Subject: [PATCH] set exit code to number of errors --- .../main/java/org/hl7/fhir/r5/validation/Validator.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/r5/validation/Validator.java b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/r5/validation/Validator.java index dd733395d..b42fdb44a 100644 --- a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/r5/validation/Validator.java +++ b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/r5/validation/Validator.java @@ -454,17 +454,19 @@ public class Validator { System.out.println(" .. validate "+sources); validator.prepare(); // generate any missing snapshots Resource r = validator.validate(sources, profiles); + int ec = 0; if (output == null) { if (r instanceof Bundle) for (BundleEntryComponent e : ((Bundle)r).getEntry()) - displayOO((OperationOutcome)e.getResource()); + ec = displayOO((OperationOutcome)e.getResource()) + ec; else - displayOO((OperationOutcome)r); + ec = displayOO((OperationOutcome)r); } else { FileOutputStream s = new FileOutputStream(output); x.compose(s, r); s.close(); } + System.exit(ec); } } } @@ -512,7 +514,7 @@ public class Validator { s.close(); } - private static void displayOO(OperationOutcome oo) { + private static int displayOO(OperationOutcome oo) { int error = 0; int warn = 0; int info = 0; @@ -532,6 +534,7 @@ public class Validator { System.out.println(getIssueSummary(issue)); } System.out.println(); + return error; } private static String getIssueSummary(OperationOutcomeIssueComponent issue) {