public void showHelp() {
      System.err.println(applicationDescription);
      System.err.println("===============================================");

      Map<NamedOption, String> optionNames = new HashMap<>();
      optionSet.forEach(option -> {
         String out = Stream.concat(
            Stream.of(option.getAliasSpecifications()),
            Stream.of(option.getSpecification()))
                            .sorted((s1, s2) -> Integer.compare(s1.length(), s2.length()))
                            .collect(Collectors.joining(", "));
         if (option.isRequired()) {
            out += " *";
         }
         optionNames.put(option, out);
      });

      int maxArgName = optionNames.values().stream().mapToInt(String::length).max().orElse(10);

      optionNames.entrySet().stream()
                 .sorted(Map.Entry.comparingByValue())
                 .forEach(entry -> {
                    String arg = entry.getValue();
                    boolean insertSpace = !arg.startsWith("--");
                    if (insertSpace) {
                       System.err.print(" ");
                    }
                    System.err.printf("%1$-" + maxArgName + "s\t", arg);
                    System.err.println(entry.getKey().getDescription());
                 });

      System.err.println("===============================================");
      System.err.println("* = Required");

   }
public void showHelp ( ) { System . err . println ( applicationDescription ) ; System . err . println ( "===============================================" ) ; Map < NamedOption , String > optionNames = new HashMap < > ( ) ; optionSet . forEach ( option -> { String out = Stream . concat ( Stream . of ( option . getAliasSpecifications ( ) ) , Stream . of ( option . getSpecification ( ) ) ) . sorted ( ( s1 , s2 ) -> Integer . compare ( s1 . length ( ) , s2 . length ( ) ) ) . collect ( Collectors . joining ( ", " ) ) ; if ( option . isRequired ( ) ) { out += " *" ; } optionNames . put ( option , out ) ; } ) ; int maxArgName = optionNames . values ( ) . stream ( ) . mapToInt ( String :: length ) . max ( ) . orElse ( 10 ) ; optionNames . entrySet ( ) . stream ( ) . sorted ( Map . Entry . comparingByValue ( ) ) . forEach ( entry -> { String arg = entry . getValue ( ) ; boolean insertSpace = ! arg . startsWith ( "--" ) ; if ( insertSpace ) { System . err . print ( " " ) ; } System . err . printf ( "%1$-" + maxArgName + "s\t" , arg ) ; System . err . println ( entry . getKey ( ) . getDescription ( ) ) ; } ) ; System . err . println ( "===============================================" ) ; System . err . println ( "* = Required" ) ; }
Prints help to standard error showing the application description, if set, and the list of valid command line
arguments with those required arguments marked with an asterisk.