List of usage examples for org.apache.commons.cli Option isRequired
public boolean isRequired()
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. java2 s .c om 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:com.marklogic.contentpump.utilities.CommandlineOption.java
public CommandlineOption(Option opt) throws IllegalArgumentException { super(opt.getOpt(), opt.hasArg(), opt.getDescription()); this.setLongOpt(opt.getLongOpt()); this.setRequired(opt.isRequired()); this.setArgName(opt.getArgName()); this.setArgs(opt.getArgs()); this.setOptionalArg(opt.hasOptionalArg()); this.setType(opt.getType()); this.setValueSeparator(opt.getValueSeparator()); }
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/* www .j a va 2s. 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; 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:gobblin.runtime.cli.PublicMethodsCliObjectFactory.java
private void printUsage(String usage, Options options) { HelpFormatter formatter = new HelpFormatter(); formatter.setOptionComparator(new Comparator<Option>() { @Override//from www .j a va 2 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()); } }); formatter.printHelp(usage, options); }
From source file:net.nicholaswilliams.java.licensing.licensor.interfaces.cli.spi.TestCliOptionsBuilder.java
@Test public void testIsRequired() { Option option = this.builder.isRequired().create("test"); assertNotNull("The option should not be null.", option); assertTrue("isRequired should be true.", option.isRequired()); }
From source file:net.nicholaswilliams.java.licensing.licensor.interfaces.cli.spi.TestCliOptionsBuilder.java
@Test public void testIsRequiredBooleanArg() { Option option = this.builder.isRequired(false).create("test"); assertNotNull("The option should not be null.", option); assertFalse("isRequired should be false.", option.isRequired()); }
From source file:co.turnus.analysis.profiler.orcc.dynamic.OrccDynamicProfilerApplication.java
@SuppressWarnings("static-access") public OrccDynamicProfilerApplication() { workspace = ResourcesPlugin.getWorkspace(); cliOptions = new Options(); {// create all the options // verbosity cliOptions.addOption("v", false, "enable verbose mode"); // help console message cliOptions.addOption("h", false, "print the help message"); // Orcc CAL Project name Option o = OptionBuilder.withArgName("name").hasArg().withType(String.class) .withDescription("Orcc CAL project name").create("p"); o.isRequired(); cliOptions.addOption(o);//from w ww .java 2 s .com // XDF file name o = OptionBuilder.withArgName("name").hasArg().withType(String.class) .withDescription("XDF top project network").create("x"); o.isRequired(); cliOptions.addOption(o); // input stimulus file file o = OptionBuilder.withArgName("file").hasArg().withType(String.class) .withDescription("input stimulus file").create("i"); cliOptions.addOption(o); // input stimulus file file o = OptionBuilder.withArgName("value").hasArg().withType(Integer.class) .withDescription("default buffer size").create("b"); cliOptions.addOption(o); // trace project name o = OptionBuilder.withArgName("name").hasArg().withType(String.class) .withDescription("generate a trace project with the given name").create("t"); cliOptions.addOption(o); // output path o = OptionBuilder.withArgName("path").hasArg().withType(String.class) .withDescription("define the output path").create("o"); o.isRequired(); cliOptions.addOption(o); // compress the execution trace cliOptions.addOption("z", false, "compress the execution trace graph file"); // store profiling data cliOptions.addOption("prof", false, "store profiling data. " + "(already enabled when the trace project is required)"); // store execution gantt chart cliOptions.addOption("gantt", false, "store the execution gantt chart"); // versioner name o = OptionBuilder.withArgName("name").hasArg().withType(String.class).withDescription("versioner name") .create("versioner"); cliOptions.addOption(o); // scheduler name o = OptionBuilder.withArgName("name").hasArg().withType(String.class).withDescription("scheduler name") .create("scheduler"); cliOptions.addOption(o); // type resize transformations o = OptionBuilder.withArgName("a,b,c").hasArgs(3).withType(Boolean.class) .withDescription("select the type resize transformations to use (true/false). \n" + "a: native ports\n" + "b: to 32 bit\n" + "c: to n bit") .create("resizer"); o.setValueSeparator(','); cliOptions.addOption(o); // stack protection cliOptions.addOption("stack-protector", false, "enable stack-protection for arrays load"); // code transformations o = OptionBuilder.withArgName("a,b,c,d,e,f").hasArgs(6).withType(Boolean.class) .withDescription("select the code transformations to use (true/false). \n" + "a: constant folding\n" + "b: constant propagation\n" + "c: dead actions\n" + "d: expression evaluation\n" + "e: dead code\n" + "f: variable initializer") .create("transfo"); o.setValueSeparator(','); cliOptions.addOption(o); } }
From source file:com.emc.ecs.sync.config.ConfigUtilTest.java
private void assertOption(org.apache.commons.cli.Option option, String longOpt, boolean required, int args, String argName) {// w w w.j ava2 s.c om Assert.assertNull(option.getOpt()); Assert.assertEquals(longOpt, option.getLongOpt()); Assert.assertEquals(required, option.isRequired()); Assert.assertEquals(args, option.getArgs()); Assert.assertEquals(argName, option.getArgName()); }
From source file:de.uni_koblenz.ist.utilities.option_handler.OptionHandler.java
/** * This method is used for adding a new Option. It stores the information if * the Option is required, sets this value to false and adds the Option to * the Options object.//from www. j a v a2s . c o m * * @param o */ public void addOption(Option o) { // backup required Status and set it to false if (o.isRequired()) { requiredOptions.add(o); o.setRequired(false); } optionList.add(o); options.addOption(o); }
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);/* www . j av a 2s.c om*/ 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()); }