List of usage examples for org.apache.commons.cli HelpFormatter setWidth
public void setWidth(int width)
From source file:com.discursive.jccook.cmdline.SomeApp.java
private static void printUsage(Options options) { HelpFormatter helpFormatter = new HelpFormatter(); helpFormatter.setWidth(80); helpFormatter.printHelp(USAGE, HEADER, options, FOOTER); }
From source file:com.damon.rocketmq.example.operation.Producer.java
public static CommandLine buildCommandline(String[] args) { final Options options = new Options(); Option opt = new Option("h", "help", false, "Print help"); opt.setRequired(false);/*w w w . j a va2 s . com*/ options.addOption(opt); opt = new Option("g", "producerGroup", true, "Producer Group Name"); opt.setRequired(true); options.addOption(opt); opt = new Option("t", "topic", true, "Topic Name"); opt.setRequired(true); options.addOption(opt); opt = new Option("a", "tags", true, "Tags Name"); opt.setRequired(true); options.addOption(opt); opt = new Option("k", "keys", true, "Keys Name"); opt.setRequired(true); options.addOption(opt); opt = new Option("c", "msgCount", true, "Message Count"); opt.setRequired(true); options.addOption(opt); PosixParser parser = new PosixParser(); HelpFormatter hf = new HelpFormatter(); hf.setWidth(110); CommandLine commandLine = null; try { commandLine = parser.parse(options, args); if (commandLine.hasOption('h')) { hf.printHelp("producer", options, true); return null; } } catch (ParseException e) { hf.printHelp("producer", options, true); return null; } return commandLine; }
From source file:com.damon.rocketmq.example.operation.Consumer.java
public static CommandLine buildCommandline(String[] args) { final Options options = new Options(); Option opt = new Option("h", "help", false, "Print help"); opt.setRequired(false);/*from w w w .ja v a2 s .c o m*/ options.addOption(opt); opt = new Option("g", "consumerGroup", true, "Consumer Group Name"); opt.setRequired(true); options.addOption(opt); opt = new Option("t", "topic", true, "Topic Name"); opt.setRequired(true); options.addOption(opt); opt = new Option("s", "subscription", true, "subscription"); opt.setRequired(false); options.addOption(opt); opt = new Option("f", "returnFailedHalf", true, "return failed result, for half message"); opt.setRequired(true); options.addOption(opt); PosixParser parser = new PosixParser(); HelpFormatter hf = new HelpFormatter(); hf.setWidth(110); CommandLine commandLine = null; try { commandLine = parser.parse(options, args); if (commandLine.hasOption('h')) { hf.printHelp("producer", options, true); return null; } } catch (ParseException e) { hf.printHelp("producer", options, true); return null; } return commandLine; }
From source file:edu.cmu.tetrad.cli.util.AppTool.java
public static void showHelp(String algorithmName, Options options) { String title = jarTitle();// ww w . jav a 2 s.c o m String version = jarVersion(); String cmdLineSyntax = (title == null || version == null) ? String.format("java -jar causal-cmd.jar --algorithm %s", algorithmName) : String.format("java -jar %s-%s.jar --algorithm %s", title, version, algorithmName); HelpFormatter formatter = new HelpFormatter(); formatter.setWidth(-1); formatter.printHelp(cmdLineSyntax, options, true); }
From source file:com.google.flightmap.parsing.faa.nfd.NfdParser.java
private static void printHelp(final CommandLine line) { final HelpFormatter formatter = new HelpFormatter(); formatter.setWidth(100); formatter.printHelp("NfdParser", OPTIONS, true); }
From source file:com.opengamma.bbg.referencedata.cache.MongoDBReferenceDataCacheRefresher.java
private static void usage(Options options) { HelpFormatter formatter = new HelpFormatter(); formatter.setWidth(120); formatter.printHelp("java " + MongoDBReferenceDataCache.class.getName() + " numberOfSecurities id", options);/* w w w. jav a 2s . co m*/ }
From source file:com.alibaba.rocketmq.example.operation.Consumer.java
public static CommandLine buildCommandline(String[] args) { final Options options = new Options(); // //////////////////////////////////////////////////// Option opt = new Option("h", "help", false, "Print help"); opt.setRequired(false);//ww w . j a va2 s .c o m options.addOption(opt); opt = new Option("g", "consumerGroup", true, "Consumer Group Name"); opt.setRequired(true); options.addOption(opt); opt = new Option("t", "topic", true, "Topic Name"); opt.setRequired(true); options.addOption(opt); opt = new Option("s", "subscription", true, "subscription"); opt.setRequired(false); options.addOption(opt); opt = new Option("f", "returnFailedHalf", true, "return failed result, for half message"); opt.setRequired(true); options.addOption(opt); // //////////////////////////////////////////////////// PosixParser parser = new PosixParser(); HelpFormatter hf = new HelpFormatter(); hf.setWidth(110); CommandLine commandLine = null; try { commandLine = parser.parse(options, args); if (commandLine.hasOption('h')) { hf.printHelp("producer", options, true); return null; } } catch (ParseException e) { hf.printHelp("producer", options, true); return null; } return commandLine; }
From source file:com.alibaba.rocketmq.example.operation.Producer.java
public static CommandLine buildCommandline(String[] args) { final Options options = new Options(); // //////////////////////////////////////////////////// Option opt = new Option("h", "help", false, "Print help"); opt.setRequired(false);//from w w w .ja va 2 s .co m options.addOption(opt); opt = new Option("g", "producerGroup", true, "Producer Group Name"); opt.setRequired(true); options.addOption(opt); opt = new Option("t", "topic", true, "Topic Name"); opt.setRequired(true); options.addOption(opt); opt = new Option("a", "tags", true, "Tags Name"); opt.setRequired(true); options.addOption(opt); opt = new Option("k", "keys", true, "Keys Name"); opt.setRequired(true); options.addOption(opt); opt = new Option("c", "msgCount", true, "Message Count"); opt.setRequired(true); options.addOption(opt); // //////////////////////////////////////////////////// PosixParser parser = new PosixParser(); HelpFormatter hf = new HelpFormatter(); hf.setWidth(110); CommandLine commandLine = null; try { commandLine = parser.parse(options, args); if (commandLine.hasOption('h')) { hf.printHelp("producer", options, true); return null; } } catch (ParseException e) { hf.printHelp("producer", options, true); return null; } return commandLine; }
From source file:com.github.brosander.java.performance.sampler.analysis.PerformanceSampleAnalyzer.java
/** * Prints the usage to System.out/*www . j a v a 2s . c om*/ * * @param errorMessage optional error message * @param options the options object to print usage for */ public static void printUsageAndExit(String errorMessage, Options options, int exitCode) { if (errorMessage != null) { System.out.println(errorMessage); System.out.println(); System.out.println(); } HelpFormatter helpFormatter = new HelpFormatter(); helpFormatter.setWidth(160); helpFormatter.printHelp("java -jar " + new File( PerformanceSampleAnalyzer.class.getProtectionDomain().getCodeSource().getLocation().getPath()) .getName(), options); System.out.flush(); System.exit(exitCode); }
From source file:com.ztesoft.zsmart.remoting.util.ServerUtil.java
/** * Description: ?commandLine<br>//from w ww .j ava2 s.c o m * * @author wang.jun<br> * @taskId <br> * @param appName * @param args * @param options * @param parser * @return <br> */ public static CommandLine parseCmdLine(final String appName, String[] args, Options options, CommandLineParser parser) { HelpFormatter hf = new HelpFormatter(); hf.setWidth(110); CommandLine commandLine = null; try { commandLine = parser.parse(options, args); if (commandLine.hasOption("h")) { hf.printHelp(appName, options, true); } } catch (ParseException e) { hf.printHelp(appName, options, true); } return commandLine; }