List of usage examples for org.apache.commons.cli Options getOptions
public Collection getOptions()
From source file:com.opengamma.integration.viewer.status.ViewStatusTool.java
@SuppressWarnings("unchecked") @Override/*from w w w. j av a2s . c om*/ protected Options createOptions(boolean contextProvided) { final Options toolOptions = super.createOptions(contextProvided); Options viewStatusOptions = ViewStatusOption.createOptions(); for (Option option : (Collection<Option>) viewStatusOptions.getOptions()) { s_logger.debug("adding {} to tool options", option); toolOptions.addOption(option); } return toolOptions; }
From source file:de.vandermeer.skb.commons.utils.Test_CLIApache.java
@Test public void testDeclareOptions() { CLIApache aca = new CLIApache(); aca.declareOptions(this.prepareComProperties()); assertEquals(6, aca.optionList.size()); for (String s : this.rows()) { assertTrue(aca.optionList.containsKey(Table.defaulSeparator + s)); }/*from w ww . ja v a2s. com*/ Options op = aca.options; assertEquals(6, op.getOptions().size()); assertTrue(op.hasOption("-b")); assertTrue(op.hasOption("-d")); assertTrue(op.hasOption("-i")); assertTrue(op.hasOption("-l")); assertTrue(op.hasOption("-s")); assertTrue(op.hasOption("--test-boolean")); assertTrue(op.hasOption("--test-double")); assertTrue(op.hasOption("--test-integer")); assertTrue(op.hasOption("--test-long")); assertTrue(op.hasOption("--test-string")); assertTrue(op.hasOption("--test-string-w-arg")); assertTrue(op.getOption("--test-string-w-arg").hasArg()); assertTrue(op.getOption("--test-string-w-arg").hasArgName()); }
From source file:ca.nines.ise.cmd.Command.java
/** * Turn the description and arguments list into nicely formatted help and * usage documentation./*from w w w .jav a 2 s . c o m*/ */ public void help() { HelpFormatter formatter = new HelpFormatter(); Options opts = getOptions(); System.out.println(description()); if (opts.getOptions().size() > 0) { formatter.printHelp(this.getClass().getSimpleName().toLowerCase() + " " + getUsage(), opts); } else { System.out.println(this.getClass().getSimpleName().toLowerCase() + " " + getUsage()); } }
From source file:com.somerledsolutions.pa11y.client.cli.OptionsBuilderTest.java
@Test public void testBuildHelpOptions() throws Exception { Options options = OptionsBuilder.buildHelpOptions(); assertEquals(1, options.getOptions().size()); assertHelpOption(options);/*from w w w. ja v a 2 s .com*/ }
From source file:com.somerledsolutions.pa11y.client.cli.OptionsBuilderTest.java
@Test public void testGetAllOptions() throws Exception { Options options = OptionsBuilder.getAllOptions(); assertEquals(11, options.getOptions().size()); assertHelpOption(options);/*from w w w . j a va 2 s.c o m*/ assertPa11yOptions(options); }
From source file:ai.grakn.migration.base.io.MigrationCLI.java
public void addOptions(Options options) { options.getOptions().forEach(defaultOptions::addOption); }
From source file:com.somerledsolutions.pa11y.client.cli.OptionsBuilderTest.java
@Test public void testBuildPa11yOptions() throws Exception { Options options = OptionsBuilder.buildPa11yOptions(); assertEquals(10, options.getOptions().size()); assertPa11yOptions(options);//from w ww . java2s. c om OptionGroup optionGroup = options.getOptionGroup(options.getOption("c")); Collection<String> optionGroupNames = optionGroup.getNames(); assertTrue(optionGroupNames.contains("c")); assertTrue(optionGroupNames.contains("l")); assertTrue(optionGroupNames.contains("r")); assertTrue(optionGroupNames.contains("g")); assertTrue(optionGroupNames.contains("d")); }
From source file:com.marklogic.shell.command.load.java
public load(Options options) { this();/* w ww .j a va2 s . co m*/ for (Iterator i = options.getOptions().iterator(); i.hasNext();) { Option o = (Option) i.next(); this.options.addOption(o); } }
From source file:iDynoOptimizer.MOEAFramework26.src.org.moeaframework.util.CommandLineUtility.java
/** * Format and display the help information that details the available * command line options. This method performs any available localization * using {@link Localization}.//from w ww . j a v a 2 s. c om * * @param options the available command line options */ private void showHelp() { Options options = getOptions(); //update the options with their descriptions for (Object object : options.getOptions()) { Option option = (Option) object; String key = "option." + option.getLongOpt(); Class<?> type = getClass(); while (CommandLineUtility.class.isAssignableFrom(type)) { if (Localization.containsKey(type, key)) { option.setDescription(Localization.getString(type, key)); break; } else { type = type.getSuperclass(); } } } //format and display the help message HelpFormatter helpFormatter = new HelpFormatter(); helpFormatter.printHelp(getCommandString(), Localization.getString(getClass(), "description"), options, Localization.getString(CommandLineUtility.class, "footer"), true); }
From source file:dioscuri.TestCommandLineInterface.java
/** * Test all valid parameters:/*from w ww. ja v a 2 s . c o m*/ * <pre> * -?,--help print this message * -a,--architecture <'16'|'32'> the cpu's architecture * -b,--boot <'floppy'|'harddisk'> the boot drive * -c,--config <file> a custom config xml file * -d,--harddisk <file> a custom hard disk image * -e,--exit used for testing purposes, will cause * Dioscuri to exit immediately * -f,--floppy <file> a custom floppy image * -h,--hide hide the GUI * -r,--autorun emulator will directly start emulatio * process * -s,--autoshutdown emulator will shutdown automatically * when emulation process is finished * </pre> * * @throws Exception - */ @Test public void testAllValid() throws Exception { Options options = parseCommandLineInterface().commandLineOptions; // no parameters is valid, of course testValid(""); // test all single options for (Object o : options.getOptions()) { Option op = (Option) o; if (!op.hasArg()) { testValid("-" + op.getOpt()); testValid("--" + op.getLongOpt()); } } // test some multiple params testValid("-he"); testValid("-h", "-e", "-s"); // test the options that need a valid input as 2nd parameter File temp = createTempFile(); if (temp != null) { // couldn't create a temp file, skip : -cfd testValid("-c", temp.getAbsolutePath()); testValid("-f", temp.getAbsolutePath()); testValid("-d", temp.getAbsolutePath()); } testValid("-b", "floppy"); testValid("-b", "HARDdisk"); // case insensitive testValid("-a", "16"); testValid("-a", "32"); }