List of usage examples for org.apache.commons.cli Option getLongOpt
public String getLongOpt()
From source file:OneParameterization.java
@SuppressWarnings("static-access") @Override// w ww. ja va2 s . c o m public Options getOptions() { Options options = super.getOptions(); options.addOption( OptionBuilder.withLongOpt("parameterFile").hasArg().withArgName("file").isRequired().create('p')); options.addOption(OptionBuilder.withLongOpt("input").hasArg().withArgName("file").isRequired().create('i')); options.addOption(OptionBuilder.withLongOpt("inputnumber").hasArg().withArgName("input number").isRequired() .create('u')); options.addOption( OptionBuilder.withLongOpt("output").hasArg().withArgName("file").isRequired().create('o')); options.addOption( OptionBuilder.withLongOpt("problem").hasArg().withArgName("name").isRequired().create('b')); options.addOption( OptionBuilder.withLongOpt("algorithm").hasArg().withArgName("name").isRequired().create('a')); options.addOption(OptionBuilder.withLongOpt("properties").hasArgs().withArgName("p1=v1;p2=v2;...") .withValueSeparator(';').create('x')); options.addOption(OptionBuilder.withLongOpt("seed").hasArg().withArgName("value").create('s')); options.addOption(OptionBuilder.withLongOpt("epsilon").hasArg().withArgName("e1,e2,...").create('e')); options.addOption(OptionBuilder.withLongOpt("metrics").create('m')); options.addOption(OptionBuilder.withLongOpt("reference").hasArg().withArgName("file").create('r')); options.addOption(OptionBuilder.withLongOpt("novariables").create('n')); options.addOption(OptionBuilder.withLongOpt("force").create('f')); //fill in option descriptions for (Object obj : options.getOptions()) { Option option = (Option) obj; option.setDescription(option.getLongOpt()); } return options; }
From source file:com.somerledsolutions.pa11y.client.cli.OptionsBuilderTest.java
private void assertCreateOption(Options options) { Option createOption = options.getOption("c"); assertEquals("c", createOption.getOpt()); assertEquals("Create task", createOption.getArgName()); assertEquals("create", createOption.getLongOpt()); assertEquals("Create a new task", createOption.getDescription()); }
From source file:com.somerledsolutions.pa11y.client.cli.OptionsBuilderTest.java
private void assertListTasksOption(Options options) { Option createOption = options.getOption("l"); assertEquals("l", createOption.getOpt()); assertEquals("List all tasks", createOption.getArgName()); assertEquals("list", createOption.getLongOpt()); assertEquals("Get all of the tasks in the application", createOption.getDescription()); }
From source file:com.somerledsolutions.pa11y.client.cli.OptionsBuilderTest.java
private void assertTaskIdOption(Options options) { Option taskIdOption = options.getOption("tid"); assertEquals("tid", taskIdOption.getOpt()); assertEquals("Task ID", taskIdOption.getArgName()); assertEquals("taskid", taskIdOption.getLongOpt()); assertEquals("The ID of the task", taskIdOption.getDescription()); assertTrue(taskIdOption.hasArg());/*from w ww . jav a2 s . co m*/ }
From source file:com.somerledsolutions.pa11y.client.cli.OptionsBuilderTest.java
private void assertLastResultOption(Options options) { Option createOption = options.getOption("lr"); assertEquals("lr", createOption.getOpt()); assertEquals("Last result", createOption.getArgName()); assertEquals("lastres", createOption.getLongOpt()); assertEquals("Include the last_result property in the output", createOption.getDescription()); }
From source file:com.emc.ecs.sync.config.ConfigWrapper.java
public C parse(CommandLine commandLine, String prefix) { try {//from w ww . j a v a 2 s. c o m C object = getTargetClass().newInstance(); BeanWrapper beanWrapper = PropertyAccessorFactory.forBeanPropertyAccess(object); for (String name : propertyNames()) { ConfigPropertyWrapper propertyWrapper = getPropertyWrapper(name); if (!propertyWrapper.isCliOption()) continue; org.apache.commons.cli.Option option = propertyWrapper.getCliOption(prefix); if (commandLine.hasOption(option.getLongOpt())) { Object value = commandLine.getOptionValue(option.getLongOpt()); if (propertyWrapper.getDescriptor().getPropertyType().isArray()) value = commandLine.getOptionValues(option.getLongOpt()); if (Boolean.class == propertyWrapper.getDescriptor().getPropertyType() || "boolean".equals(propertyWrapper.getDescriptor().getPropertyType().getName())) value = Boolean.toString(!propertyWrapper.isCliInverted()); beanWrapper.setPropertyValue(name, value); } } return object; } catch (InstantiationException | IllegalAccessException e) { throw new RuntimeException(e); } }
From source file:net.nicholaswilliams.java.licensing.licensor.interfaces.cli.spi.TestCliOptionsBuilder.java
@Test public void testWithLongOpt() { Option option = this.builder.withLongOpt("longOpt01").create("test"); assertNotNull("The option should not be null.", option); assertEquals("The long opt is not correct.", "longOpt01", option.getLongOpt()); }
From source file:com.somerledsolutions.pa11y.client.cli.OptionsBuilderTest.java
private void assertDeleteOption(Options options) { Option deleteTaskOption = options.getOption("d"); assertEquals("d", deleteTaskOption.getOpt()); assertEquals("Delete", deleteTaskOption.getArgName()); assertEquals("delete", deleteTaskOption.getLongOpt()); assertEquals("Delete a task by ID", deleteTaskOption.getDescription()); }
From source file:com.zuehlke.sbdfx.utils.CampApplBase.java
protected String getOptionValue(final Option option, final String defaultValue) { String result = commandLine.getOptionValue(option.getLongOpt(), "").trim(); //$NON-NLS-1$ if (result.length() > 0) { return result; }// w ww . j a va 2 s .c om final String longOpt = option.getLongOpt(); result = propertiesFromConfigFile.getProperty(longOpt, "").trim(); //$NON-NLS-1$ if (result.length() > 0) { return result; } if (defaultValue != null) { return defaultValue; } throw new IllegalArgumentException("Missing value for required option " + longOpt); //$NON-NLS-1$ }
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(/*ww w . j av a2s . c o m*/ "The accessibility standard to test the URL against. Must be one of Section508, WCAG2A, WCAG2AA, WCAG2AAA", createOption.getDescription()); }