()
| 312 | } |
| 313 | |
| 314 | @SuppressForbidden(reason = "System.out for formatting") |
| 315 | public static HelpFormatter getFormatter() { |
| 316 | TextHelpAppendable helpAppendable = |
| 317 | new TextHelpAppendable(System.out) { |
| 318 | @Override |
| 319 | public void appendTable(TableDefinition table) throws IOException { |
| 320 | if (table == null) { |
| 321 | return; |
| 322 | } |
| 323 | // Create a new TableDefinition with empty headers to suppress the header row |
| 324 | List<String> emptyHeaders = Collections.nCopies(table.headers().size(), ""); |
| 325 | TableDefinition noHeaderTable = |
| 326 | TableDefinition.from( |
| 327 | table.caption(), table.columnTextStyles(), emptyHeaders, table.rows()); |
| 328 | super.appendTable(noHeaderTable); |
| 329 | } |
| 330 | |
| 331 | @Override |
| 332 | public void appendParagraph(CharSequence paragraph) throws IOException { |
| 333 | String text = paragraph.toString().stripTrailing(); |
| 334 | if (!text.isEmpty()) { |
| 335 | super.append(text); |
| 336 | super.append("\n"); |
| 337 | } |
| 338 | } |
| 339 | }; |
| 340 | helpAppendable.setMaxWidth(120); |
| 341 | helpAppendable.setIndent(0); |
| 342 | helpAppendable.setLeftPad(0); |
| 343 | HelpFormatter formatter = |
| 344 | HelpFormatter.builder().setHelpAppendable(helpAppendable).setShowSince(false).get(); |
| 345 | formatter.setSyntaxPrefix("usage:"); |
| 346 | return formatter; |
| 347 | } |
| 348 | |
| 349 | /** Scans Jar files on the classpath for Tool implementations to activate. */ |
| 350 | private static List<Class<? extends Tool>> findToolClassesInPackage(String packageName) { |
no test coverage detected