List of usage examples for org.apache.commons.cli HelpFormatter setOptionComparator
public void setOptionComparator(Comparator comparator)
From source file:guru.nidi.raml.doc.OptionParser.java
public void showHelp() { HelpFormatter formatter = new HelpFormatter(); formatter.setWidth(80);/* w w w . j a v a2s .c o m*/ formatter.setOptionComparator(optionComparator()); formatter.printHelp("java -jar raml-doc-standalone.jar RAML-1 [RAML-2 ...] [options]", helpHeader(), createOptions(), "", false); }
From source file:com.github.horrorho.liquiddonkey.settings.commandline.CommandLineConfigFactory.java
public Config fromArgs(String[] args) { logger.trace("<< fromArgs() < {}", (Object) args); try {/* ww w . ja v a 2s .co m*/ PropertiesFactory factory = PropertiesFactory.create(); // Fallback defaults Properties properties = factory.fromDefaults(); // Jar defaults try { String resource = properties.get(Property.PROPERTIES_JAR.name()).toString(); IOSupplier<InputStream> supplier = () -> this.getClass().getResourceAsStream(resource); properties = factory.fromInputStream(properties, supplier); } catch (IOException ex) { logger.warn("-- fromArgs() > exception: ", ex); } // Command line args CommandLineOptions commandLineOptions = CommandLineOptions.from(properties); properties = CommandLinePropertiesFactory.create().from(properties, commandLineOptions, args); if (properties.containsKey(Property.COMMAND_LINE_HELP.name())) { HelpFormatter helpFormatter = new HelpFormatter(); helpFormatter.setOptionComparator(null); helpFormatter.printHelp(properties.getProperty(Property.APP_NAME.name()) + " [OPTION]... (<token> | <appleid> <password>) ", commandLineOptions.options()); return null; } if (properties.containsKey(Property.COMMAND_LINE_VERSION.name())) { System.out.println(properties.getProperty(Property.PROJECT_VERSION.name())); return null; } // Build config Config config = Config.from(properties); logger.trace(">> fromArgs() > {}", config); return config; } catch (ParseException | IllegalArgumentException | IllegalStateException ex) { logger.trace("-- fromArgs() > exception: ", ex); System.out.println(ex.getLocalizedMessage()); System.out.println("Try '--help' for more information."); return null; } }
From source file:gobblin.runtime.StateStoreBasedWatermarkStorageCli.java
private void printUsage(Options options) { HelpFormatter formatter = new HelpFormatter(); formatter.setOptionComparator(new Comparator<Option>() { @Override/*from w w w . j a va2 s . co m*/ public int compare(Option o1, Option o2) { if (o1.isRequired() && !o2.isRequired()) { return -1; } if (!o1.isRequired() && o2.isRequired()) { return 1; } return o1.getOpt().compareTo(o2.getOpt()); } }); String usage = "gobblin watermarks "; formatter.printHelp(usage, options); }
From source file:gobblin.runtime.cli.CliEmbeddedGobblin.java
private void printUsage(String alias, Options options, EmbeddedGobblinCliFactory factory) { HelpFormatter formatter = new HelpFormatter(); formatter.setOptionComparator(new Comparator<Option>() { @Override//ww w . j a v a 2 s . c o m public int compare(Option o1, Option o2) { if (o1.isRequired() && !o2.isRequired()) { return -1; } if (!o1.isRequired() && o2.isRequired()) { return 1; } return o1.getOpt().compareTo(o2.getOpt()); } }); String usage; if (Strings.isNullOrEmpty(alias)) { usage = "gobblin run [listQuickApps] [<quick-app>] " + factory.getUsageString(); } else { usage = "gobblin run " + alias + " " + factory.getUsageString(); } formatter.printHelp(usage, options); }
From source file:chiliad.parser.pdf.cli.ParserCli.java
public void showHelpMessage() { HelpFormatter helpFormatter = new HelpFormatter(); helpFormatter.setOptionComparator(new FixedOrderComparator(options.getOptions().toArray())); helpFormatter.setOptPrefix(optionPrefix); helpFormatter.printHelp(helpMessage, options); }
From source file:com.teradata.tempto.runner.TemptoRunnerCommandLineParser.java
public void printHelpMessage(PrintWriter printWriter) { Options options = buildOptions();// ww w .ja v a2 s. c om HelpFormatter helpFormatter = new HelpFormatter(); helpFormatter.setOptionComparator(OPTION_BY_LONG_OPT_COMPARATOR); helpFormatter.printHelp(printWriter, 120, appName, null, options, HelpFormatter.DEFAULT_LEFT_PAD, HelpFormatter.DEFAULT_DESC_PAD, null); printWriter.flush(); }
From source file:gobblin.runtime.cli.PublicMethodsCliObjectFactory.java
private void printUsage(String usage, Options options) { HelpFormatter formatter = new HelpFormatter(); formatter.setOptionComparator(new Comparator<Option>() { @Override/*from w w w . ja v a 2 s. c o m*/ public int compare(Option o1, Option o2) { if (o1.isRequired() && !o2.isRequired()) { return -1; } if (!o1.isRequired() && o2.isRequired()) { return 1; } return o1.getOpt().compareTo(o2.getOpt()); } }); formatter.printHelp(usage, options); }
From source file:net.jsign.PESignerCLI.java
private void printHelp() { String header = "Sign and timestamp a Windows executable file.\n\n"; String footer = "\nPlease report suggestions and issues on the GitHub project at https://github.com/ebourg/jsign/issues"; HelpFormatter formatter = new HelpFormatter(); formatter.setOptionComparator(null); formatter.setWidth(85);//w ww .ja va2s.c o m formatter.setDescPadding(1); formatter.printHelp("java -jar jsign.jar [OPTIONS] FILE", header, options, footer); }
From source file:ca.appbox.monitoring.jmx.jmxbox.commons.context.parser.JmxContextParserImpl.java
private void displayUsage() { // FIXME : Send a wrapped print writer to keep control over the app // output.//from w ww . jav a2 s . c om HelpFormatter helpFormatter = new HelpFormatter(); helpFormatter.setOptionComparator(new CommandLineOptionsComparator()); helpFormatter.printHelp(JmxClientApp.class.getSimpleName(), options); }
From source file:net.sourceforge.jencrypt.CommandLineHelper.java
/** * Formatter for printing the help text describing command line options. The * options are ordered as they appear in indexOfOptions. * /*from ww w .ja v a2 s.c o m*/ * @param indexOfOptions * @return */ private HelpFormatter getHelpFormatter(final String indexOfOptions) { HelpFormatter helpFormatter = new HelpFormatter(); helpFormatter.setOptionComparator(new Comparator<Option>() { public int compare(Option o1, Option o2) { return indexOfOptions.indexOf(o1.getOpt()) - indexOfOptions.indexOf(o2.getOpt()); } }); return helpFormatter; }