code: public static void printHelp(final Options options) {
          Collection<Option> c = options.getOptions();
          System.out.println("Command line options are:");
          int longestLongOption = 0;
          for (Option op : c) {
              if (op.getLongOpt().length() > longestLongOption) {
                  longestLongOption = op.getLongOpt().length();
              }
          }
  
          longestLongOption += 2;
          String spaces = StringUtils.repeat(" ", longestLongOption);
  
          for (Option op : c) {
              System.out.print("\t-" + op.getOpt() + " --" + op.getLongOpt());
              if (op.getLongOpt().length() < spaces.length()) {
                  System.out.print(spaces.substring(op.getLongOpt().length()));
              } else {
                  System.out.print(" ");
              }
              System.out.println(op.getDescription());
          }
      }
docs: Prints the help on the command line
  
  @param options Options object from commons-cli