List of usage examples for org.apache.commons.cli Option getDescription
public String getDescription()
From source file:com.github.mrstampy.poisonivy.PoisonIvy.java
/** * Prints the help message to System.out. *//*from www . ja v a2 s. c o m*/ protected void printHelpMessage() { out.println("Poison Ivy - Java Library Dependency Resolver and Application Launcher"); out.println(); out.println("Licence: GPL 2.0"); out.println("Copyright Burton Alexander 2014"); out.println(); out.println("Usage: "); out.println(); Options opts = getOptions(); for (Object op : opts.getOptions()) { Option o = (Option) op; out.println("-" + o.getOpt() + (o.hasArg() ? " [ARG]" : "") + " - " + o.getDescription()); } out.println(); out.println("The required options can be put into a file named '" + POISONIVY_CONFIG + "'"); out.println(); printExamples(); out.println(); out.println("See http://mrstampy.github.io/PoisonIvy/ for more information"); }
From source file:com.netflix.exhibitor.standalone.ExhibitorCLI.java
private void logOptions(String sectionName, String prefix, Options options) { if (sectionName != null) { log.info("== " + sectionName + " =="); }//from ww w . j av a2 s .c o m //noinspection unchecked for (Option option : (Iterable<? extends Option>) options.getOptions()) { if (option.hasLongOpt()) { if (option.hasArg()) { log.info(prefix + option.getLongOpt() + " <arg> - " + option.getDescription()); } else { log.info(prefix + option.getLongOpt() + " - " + option.getDescription()); } } } }
From source file:com.bc.fiduceo.post.PostProcessingToolTest.java
@Test public void testOptions() { final Options options = PostProcessingTool.getOptions(); assertEquals(6, options.getOptions().size()); Option o; o = options.getOption("c"); assertNotNull(o);//from w w w . jav a2 s . com assertEquals("config", o.getLongOpt()); assertEquals("Defines the configuration directory. Defaults to './config'.", o.getDescription()); assertEquals(true, o.hasArg()); assertEquals(false, o.isRequired()); o = options.getOption("i"); assertNotNull(o); assertEquals("input-dir", o.getLongOpt()); assertEquals("Defines the path to the input mmd files directory.", o.getDescription()); assertEquals(true, o.hasArg()); assertEquals(true, o.isRequired()); o = options.getOption("end"); assertNotNull(o); assertEquals("end-date", o.getLongOpt()); assertEquals("Defines the processing end-date, format 'yyyy-DDD'. DDD = Day of year.", o.getDescription()); assertEquals(true, o.hasArg()); assertEquals(true, o.isRequired()); o = options.getOption("h"); assertNotNull(o); assertEquals("help", o.getLongOpt()); assertEquals("Prints the tool usage.", o.getDescription()); assertEquals(false, o.hasArg()); assertEquals(false, o.isRequired()); o = options.getOption("j"); assertNotNull(o); assertEquals("job-config", o.getLongOpt()); assertEquals( "Defines the path to post processing job configuration file. Path is relative to the configuration directory.", o.getDescription()); assertEquals(true, o.hasArg()); assertEquals(true, o.isRequired()); o = options.getOption("start"); assertNotNull(o); assertEquals("start-date", o.getLongOpt()); assertEquals("Defines the processing start-date, format 'yyyy-DDD'. DDD = Day of year.", o.getDescription()); assertEquals(true, o.hasArg()); assertEquals(true, o.isRequired()); }
From source file:com.somerledsolutions.pa11y.client.cli.OptionsBuilderTest.java
private void assertStandardOption(Options options) { Option createOption = options.getOption("s"); assertEquals("s", createOption.getOpt()); assertEquals("Accessibility standard", createOption.getArgName()); assertEquals("standard", createOption.getLongOpt()); assertEquals(//w w w . ja v a2s . c o m "The accessibility standard to test the URL against. Must be one of Section508, WCAG2A, WCAG2AA, WCAG2AAA", createOption.getDescription()); }
From source file:com.zimbra.cs.volume.VolumeCLI.java
private void printOpt(String optStr, int leftPad) { Options options = getOptions();//from ww w .j av a 2s . co m Option opt = options.getOption(optStr); StringBuilder buf = new StringBuilder(); buf.append(Strings.repeat(" ", leftPad)); buf.append('-').append(opt.getOpt()).append(",--").append(opt.getLongOpt()); if (opt.hasArg()) { buf.append(" <arg>"); } buf.append(Strings.repeat(" ", 35 - buf.length())); buf.append(opt.getDescription()); System.err.println(buf.toString()); }
From source file:com.bc.fiduceo.matchup.MatchupToolTest.java
@Test public void testGetOptions() { final Options options = MatchupTool.getOptions(); assertNotNull(options);// w ww. j a v a2 s. com final Option helpOption = options.getOption("h"); assertNotNull(helpOption); assertEquals("h", helpOption.getOpt()); assertEquals("help", helpOption.getLongOpt()); assertEquals("Prints the tool usage.", helpOption.getDescription()); assertFalse(helpOption.hasArg()); final Option configOption = options.getOption("config"); assertNotNull(configOption); assertEquals("c", configOption.getOpt()); assertEquals("config", configOption.getLongOpt()); assertEquals("Defines the configuration directory. Defaults to './config'.", configOption.getDescription()); assertTrue(configOption.hasArg()); final Option startOption = options.getOption("start"); assertNotNull(startOption); assertEquals("start", startOption.getOpt()); assertEquals("start-date", startOption.getLongOpt()); assertEquals("Defines the processing start-date, format 'yyyy-DDD'", startOption.getDescription()); assertTrue(startOption.hasArg()); final Option endOption = options.getOption("end"); assertNotNull(endOption); assertEquals("end", endOption.getOpt()); assertEquals("end-date", endOption.getLongOpt()); assertEquals("Defines the processing end-date, format 'yyyy-DDD'", endOption.getDescription()); assertTrue(endOption.hasArg()); final Option useCaseOption = options.getOption("usecase"); assertNotNull(useCaseOption); assertEquals("u", useCaseOption.getOpt()); assertEquals("usecase", useCaseOption.getLongOpt()); assertEquals( "Defines the path to the use-case configuration file. Path is relative to the configuration directory.", useCaseOption.getDescription()); assertTrue(useCaseOption.hasArg()); }
From source file:kieker.tools.util.CLIHelpFormatter.java
@SuppressWarnings("unchecked") @Override/* w w w . j a va2 s . c om*/ protected StringBuffer renderOptions(final StringBuffer sb, final int width, final Options options, final int leftPad, final int descPad) { final String lpad = this.createPadding(leftPad); final String dpad = this.createPadding(8); // we use a fixed value instead of descPad StringBuilder optBuf; final List<Option> optList = new ArrayList<Option>(options.getOptions()); Collections.sort(optList, this.getOptionComparator()); for (final Iterator<Option> i = optList.iterator(); i.hasNext();) { final Option option = i.next(); optBuf = new StringBuilder(8); if (option.getOpt() == null) { optBuf.append(lpad).append(" ").append(this.getLongOptPrefix()).append(option.getLongOpt()); } else { optBuf.append(lpad).append(this.getOptPrefix()).append(option.getOpt()); if (option.hasLongOpt()) { optBuf.append(',').append(this.getLongOptPrefix()).append(option.getLongOpt()); } } if (option.hasArg()) { if (option.hasArgName()) { optBuf.append(" <").append(option.getArgName()).append('>'); } else { optBuf.append(' '); } } sb.append(optBuf.toString()).append(this.getNewLine()); optBuf = new StringBuilder(); optBuf.append(dpad); if (option.getDescription() != null) { optBuf.append(option.getDescription()); } this.renderWrappedText(sb, width, dpad.length(), optBuf.toString()); if (i.hasNext()) { sb.append(this.getNewLine()); sb.append(this.getNewLine()); } } return sb; }
From source file:com.buildml.main.BMLAdminMain.java
/** * Display a set of options (as defined by the Options class). This methods is used * in displaying the help text./* ww w.j a v a 2s .c om*/ * @param opts A set of command line options, as defined by the Options class. */ @SuppressWarnings("unchecked") private void displayOptions(Options opts) { /* obtain a list of all the options */ Collection<Option> optList = opts.getOptions(); /* if there are no options for this command ... */ if (optList.size() == 0) { System.err.println(" No options available."); } /* * Else, we have options to display. Show them in a nicely tabulated * format, with the short option name (e.g. -p) and the long option name * (--show-pkgs) first, followed by a text description of the option. */ else { for (Iterator<Option> iterator = optList.iterator(); iterator.hasNext();) { Option thisOpt = iterator.next(); String shortOpt = thisOpt.getOpt(); String longOpt = thisOpt.getLongOpt(); String line = " "; if (shortOpt != null) { line += "-" + shortOpt; } else { line += " "; } if (shortOpt != null && longOpt != null) { line += " | "; } else { line += " "; } if (longOpt != null) { line += "--" + thisOpt.getLongOpt(); } if (thisOpt.hasArg()) { line += " <" + thisOpt.getArgName() + ">"; } formattedDisplayLine(line, thisOpt.getDescription()); } } }
From source file:net.sf.clichart.main.FixedHelpFormatter.java
protected StringBuffer renderOptions(StringBuffer sb, int width, Options options, int leftPad, int descPad) { final String lpad = createPadding(leftPad); final String dpad = createPadding(descPad); //first create list containing only <lpad>-a,--aaa where -a is opt and --aaa is //long opt; in parallel look for the longest opt string //this list will be then used to sort options ascending int max = 0;// w ww . j a va 2 s .c o m StringBuffer optBuf; List prefixList = new ArrayList(); Option option; //List optList = options.helpOptions(); Collection optionsCollection = options.getOptions(); List optList = new ArrayList(optionsCollection); Collections.sort(optList, new StringBufferComparator()); for (Iterator i = optList.iterator(); i.hasNext();) { option = (Option) i.next(); optBuf = new StringBuffer(8); if (option.getOpt().equals(" ")) { optBuf.append(lpad).append(" " + defaultLongOptPrefix).append(option.getLongOpt()); } else { optBuf.append(lpad).append(defaultOptPrefix).append(option.getOpt()); if (option.hasLongOpt()) { optBuf.append(',').append(defaultLongOptPrefix).append(option.getLongOpt()); } } if (option.hasArg()) { if (option.hasArgName()) { optBuf.append(" <").append(option.getArgName()).append('>'); } else { optBuf.append(' '); } } prefixList.add(optBuf); max = optBuf.length() > max ? optBuf.length() : max; } int x = 0; for (Iterator i = optList.iterator(); i.hasNext();) { option = (Option) i.next(); optBuf = new StringBuffer(prefixList.get(x++).toString()); if (optBuf.length() < max) { optBuf.append(createPadding(max - optBuf.length())); } optBuf.append(dpad); int nextLineTabStop = max + descPad; renderWrappedText(sb, width, nextLineTabStop, optBuf.append(option.getDescription()).toString()); if (i.hasNext()) { sb.append(defaultNewLine); } } return sb; }
From source file:nl.systemsgenetics.eqtlinteractionanalyser.eqtlinteractionanalyser.createOptionsListForManual.java
/** * @param args the command line arguments *///from w ww .ja v a 2 s . c om public static void main(String[] args) { Options options = EQTLInteractionAnalyser.OPTIONS; System.out.println("| Short | Long | Description |"); System.out.println("|-------|------|-------------|"); for (Object optionO : options.getOptions()) { Option option = (Option) optionO; System.out.print("| -"); System.out.print(option.getOpt()); System.out.print(" | --"); System.out.print(option.getLongOpt()); System.out.print(" | "); System.out.print(option.getDescription()); System.out.println(" | "); } }