List of usage examples for org.apache.commons.cli Option setLongOpt
public void setLongOpt(String longOpt)
From source file:org.eclipse.emf.mwe.core.WorkflowRunner.java
@SuppressWarnings("static-access") protected static CommandLine getCommandLine(String[] args) throws ParseException { final Options options = new Options(); options.addOption(OptionBuilder.hasArgs().withArgName("className,moreArgs").withDescription( "the name of a class that implements ProgressMonitor. More arguments can be appended that will be injected to the monitor," + " if it has a init(String[] args) method.") .withLongOpt("monitorClass").withValueSeparator(',').create(MONITOR)); options.addOption(OptionBuilder.withLongOpt("ant").withDescription("must be set when using in Ant context") .create(ANT));/*from w w w .java2 s .c o m*/ final Option paramOption = OptionBuilder.withArgName("key=value") .withDescription("external property that is handled as workflow property").hasArgs().create(PARAM); paramOption.setLongOpt("param"); options.addOption(paramOption); options.addOption(OptionBuilder.hasArgs().withArgName("className").withDescription( "the name of a class that implements a public method 'public void processCmdLine(String[] cmdLineArgs, Map paramsToUseInWorkflow, WorkflowContext ctx)'.") .withLongOpt("cmdLineProcessor").create(CMDL)); final Option runnerOption = OptionBuilder.withArgName("className") .withDescription("WorkflowRunnerEngine class").hasArgs().create(ENGINE); runnerOption.setLongOpt("engine"); options.addOption(runnerOption); // create the parser final CommandLineParser parser = new PosixParser(); CommandLine line = parser.parse(options, args); return line; }
From source file:org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher.java
@SuppressWarnings("static-access") public Options getOptions() { final Options options = new Options(); final Option paramOption = OptionBuilder.withArgName("key=value") .withDescription("external property that is handled as workflow property").hasArgs().create(PARAM); paramOption.setLongOpt("param"); options.addOption(paramOption);// w w w. ja v a 2 s. c o m return options; }
From source file:org.eclipse.jubula.app.autrun.AutRunApplication.java
/** * @return the command line options available when invoking the main method. *///from w ww . j a va 2 s . com private static Options createCmdLineOptions() { Options options = new Options(); Option autAgentHostOption = new Option(OPT_AUT_AGENT_HOST, true, NLS.bind(Messages.infoAutAgentHost, DEFAULT_AUT_AGENT_HOST)); autAgentHostOption.setLongOpt(OPT_AUT_AGENT_HOST_LONG); autAgentHostOption.setArgName(HOSTNAME); options.addOption(autAgentHostOption); Option autAgentPortOption = new Option(OPT_AUT_AGENT_PORT, true, NLS.bind(Messages.infoAutAgentPort, DEFAULT_AUT_AGENT_PORT)); autAgentPortOption.setLongOpt(OPT_AUT_AGENT_PORT_LONG); autAgentPortOption.setArgName(PORT); options.addOption(autAgentPortOption); OptionGroup autToolkitOptionGroup = new OptionGroup(); autToolkitOptionGroup.addOption(new Option(TK_SWING, Messages.infoSwingToolkit)); autToolkitOptionGroup.addOption(new Option(TK_SWT, Messages.infoSwtToolkit)); autToolkitOptionGroup.addOption(new Option(TK_RCP, Messages.infoRcpToolkit)); autToolkitOptionGroup.setRequired(true); options.addOptionGroup(autToolkitOptionGroup); Option autIdOption = new Option(OPT_AUT_ID, true, Messages.infoAutId); autIdOption.setLongOpt(OPT_AUT_ID_LONG); autIdOption.setArgName(ID); autIdOption.setRequired(true); options.addOption(autIdOption); Option nameTechnicalComponentsOption = new Option(OPT_NAME_TECHNICAL_COMPONENTS, true, Messages.infoGenerateTechnicalComponentNames); nameTechnicalComponentsOption.setLongOpt(OPT_NAME_TECHNICAL_COMPONENTS_LONG); nameTechnicalComponentsOption.setArgName(TRUE_FALSE); options.addOption(nameTechnicalComponentsOption); Option keyboardLayoutOption = new Option(OPT_KEYBOARD_LAYOUT, true, Messages.infoKbLayout); keyboardLayoutOption.setLongOpt(OPT_KEYBOARD_LAYOUT_LONG); keyboardLayoutOption.setArgName(LOCALE); options.addOption(keyboardLayoutOption); Option workingDirOption = new Option(OPT_WORKING_DIR, true, Messages.infoAutWorkingDirectory); workingDirOption.setLongOpt(OPT_WORKING_DIR_LONG); workingDirOption.setArgName(DIRECTORY); options.addOption(workingDirOption); Option helpOption = new Option(OPT_HELP, false, Messages.infoHelp); helpOption.setLongOpt(OPT_HELP_LONG); options.addOption(helpOption); OptionBuilder.hasArgs(); Option autExecutableFileOption = OptionBuilder.create(OPT_EXECUTABLE); autExecutableFileOption.setDescription(Messages.infoExecutableFile); autExecutableFileOption.setLongOpt(OPT_EXECUTABLE_LONG); autExecutableFileOption.setRequired(true); autExecutableFileOption.setArgName(COMMAND); options.addOption(autExecutableFileOption); return options; }
From source file:org.uli.util.MyOptionBuilder.java
/** * Create an Option using the current settings and with * the specified Option <code>char</code>. * * @param opt the <code>java.lang.String</code> representation * of the Option//from w ww . j a v a 2s . c om * @return the Option instance * @throws IllegalArgumentException if <code>opt</code> is not * a valid character. See Option. */ public Option create(String opt) throws IllegalArgumentException { Option option = null; try { // create the option option = new Option(opt, description); // set the option properties option.setLongOpt(longopt); option.setRequired(required); option.setOptionalArg(optionalArg); option.setArgs(numberOfArgs); option.setType(type); option.setValueSeparator(valuesep); option.setArgName(argName); } finally { // reset the OptionBuilder properties this.reset(); } // return the Option instance return option; }
From source file:org.zend.sdkcli.internal.options.DetectOptionUtility.java
private static void addBoolean(Options options, Method method) { final Option a = method.getAnnotation(Option.class); // create option object final org.apache.commons.cli.Option o = new org.apache.commons.cli.Option(a.opt(), a.description()); if (a.longOpt() != null && a.longOpt().length() > 0) { o.setLongOpt(a.longOpt()); }/*from ww w . j a v a 2 s . c o m*/ o.setArgs(0); o.setRequired(a.required()); // assign to options list options.addOption(o); options.addOption(o); }
From source file:org.zend.sdkcli.internal.options.DetectOptionUtility.java
private static void addString(Options options, Method method) { final Option a = method.getAnnotation(Option.class); // create option object final org.apache.commons.cli.Option o = new org.apache.commons.cli.Option(a.opt(), a.description()); if (a.longOpt() != null && a.longOpt().length() > 0) { o.setLongOpt(a.longOpt()); }// w w w . j av a2 s. com o.setArgs(a.numberOfArgs()); o.setRequired(a.required()); o.setType(a.type()); o.setArgName(a.argName()); // assign to options list options.addOption(o); }