Delegates to tool specified on the command-line.
(String[] args)
| 61 | * Delegates to tool specified on the command-line. |
| 62 | */ |
| 63 | private int run(String[] args) throws Exception { |
| 64 | if (args.length != 0) { |
| 65 | Tool tool = tools.get(args[0]); |
| 66 | if (tool != null) { |
| 67 | return tool.run(System.in, System.out, System.err, Arrays.asList(args).subList(1, args.length)); |
| 68 | } |
| 69 | } |
| 70 | System.err.print("Version "); |
| 71 | try (InputStream versionInput = Main.class.getClassLoader().getResourceAsStream("VERSION.txt")) { |
| 72 | printStream(versionInput); |
| 73 | } |
| 74 | System.err.print(" of "); |
| 75 | try (InputStream noticeInput = Main.class.getClassLoader().getResourceAsStream("META-INF/NOTICE")) { |
| 76 | printHead(noticeInput, 5); |
| 77 | } |
| 78 | System.err.println("----------------"); |
| 79 | |
| 80 | System.err.println("Available tools:"); |
| 81 | for (Tool k : tools.values()) { |
| 82 | System.err.printf("%" + maxLen + "s %s\n", k.getName(), k.getShortDescription()); |
| 83 | } |
| 84 | |
| 85 | return 1; |
| 86 | } |
| 87 | |
| 88 | private static void printStream(InputStream in) throws Exception { |
| 89 | byte[] buffer = new byte[1024]; |
nothing calls this directly
no test coverage detected