Source:
public static void main(String[] args) { if (args.length == 0) { System.err.println( "Usage: java -DplatformType=ILLUMINA -Dname=America/Toronto -Dtz=local uk.ac.bbsrc.tgac.miso.runscanner.Main /path/to/run/folder"); } String platformName = System.getProperty("platformType"); if (platformName == null) { System.err.println("Please set -DplatformType=X where X is one of:"); Arrays.stream(PlatformType.values()).map(PlatformType::name).forEach(System.err::println); System.exit(1); } String tzId = System.getProperty("tz"); TimeZone tz; if (tzId == null) { tz = TimeZone.getDefault(); } else { tz = TimeZone.getTimeZone(tzId); } PlatformType pt = PlatformType.valueOf(platformName); String name = System.getProperty("name", "default"); for (RunProcessor rp : RunProcessor.INSTANCES) { if (rp.getPlatformType() == pt && rp.getName().equals(name)) { List<NotificationDto> results = new ArrayList<>(); boolean success = true; for (String path : args) { File directory = new File(path); if (!directory.isDirectory() || !directory.canExecute() || !directory.canExecute()) { System.err.println("Target is not a useable directory: " + path); success = false; continue; } NotificationDto result = rp.apply(directory, tz).get(); if (result == null) { System.err.println("Cannot process directory: " + path); success = false; } else { results.add(result); } } ObjectMapper mapper = new ObjectMapper(); try { mapper.writeValue(System.out, results); } catch (IOException e) { e.printStackTrace(); System.exit(1); } System.exit(success ? 0 : 2); } } System.err.println("Cannot find a run processor that matches."); System.exit(1); }

Target:
public static void main(String[] args) { if (args.length == 0) { System.err.println( "Usage: java -DplatformType=ILLUMINA -Dname=default -Dtz=America/Toronto uk.ac.bbsrc.tgac.miso.runscanner.Main /path/to/run/folder"); } String platformName = System.getProperty("platformType"); if (platformName == null) { System.err.println("Please set -DplatformType=X where X is one of:"); Arrays.stream(PlatformType.values()).map(PlatformType::name).forEach(System.err::println); System.exit(1); } String tzId = System.getProperty("tz"); TimeZone tz; if (tzId == null) { tz = TimeZone.getDefault(); } else { tz = TimeZone.getTimeZone(tzId); } PlatformType pt = PlatformType.valueOf(platformName); String name = System.getProperty("name", "default"); for (RunProcessor rp : RunProcessor.INSTANCES) { if (rp.getPlatformType() == pt && rp.getName().equals(name)) { List<NotificationDto> results = new ArrayList<>(); boolean success = true; for (String path : args) { File directory = new File(path); if (!directory.isDirectory() || !directory.canExecute() || !directory.canRead()) { System.err.println("Target is not a useable directory: " + path); success = false; continue; } try { results.add(rp.process(directory, tz)); } catch (Exception e) { System.err.println("Cannot process directory: " + path); e.printStackTrace(); success = false; } } ObjectMapper mapper = new ObjectMapper(); try { mapper.writeValue(System.out, results); } catch (IOException e) { e.printStackTrace(); System.exit(1); } System.exit(success ? 0 : 2); } } System.err.println("Cannot find a run processor that matches."); System.exit(1); }