List of usage examples for org.apache.commons.cli Option setRequired
public void setRequired(boolean required)
From source file:com.opengamma.integration.tool.marketdata.CurveFutureSecurityLoaderTool.java
@Override protected Options createOptions(final boolean contextProvided) { final Options options = super.createOptions(contextProvided); final Option curveNameOption = new Option(CURVE_NAME_OPT, "name", true, "The name of the yield curve definition for which to resolve time series"); curveNameOption.setRequired(true); options.addOption(curveNameOption);// w w w . ja va 2 s .com final Option writeOption = new Option(WRITE_OPT, "write", false, "Actually persists the time series to the database if specified, otherwise pretty-prints without persisting"); options.addOption(writeOption); final Option verboseOption = new Option(VERBOSE_OPT, "verbose", false, "Displays progress messages on the terminal"); options.addOption(verboseOption); return options; }
From source file:edu.cornell.med.icb.geo.tools.GDS2InsightfulMiner.java
private void proccess(final String[] args) { // create the Options final Options options = new Options(); // help/*from w w w. j av a 2 s.c o m*/ options.addOption("h", "help", false, "print this message"); // input file name final Option inputOption = new Option("i", "input", true, "specify a GEO data set file (GDS file)"); inputOption.setArgName("file"); inputOption.setRequired(true); options.addOption(inputOption); // output file name final Option outputOption = new Option("o", "output", true, "specify the destination file"); outputOption.setArgName("file"); outputOption.setRequired(true); options.addOption(outputOption); // label values final Option labelOptions = new Option("l", "label", true, "specify a label to tag a set of columns"); labelOptions.setArgName("double-value"); labelOptions.setRequired(false); options.addOption(labelOptions); // group file names final Option groupOptions = new Option("g", "group", true, "specify a file that named columns associated to a label. Each -group option must match a -label option. Matching is done according to the order on the command line. Each line of the group file identifies a column in the GEO data set that is to be labeled according to the corresponding label"); groupOptions.setArgName("file"); groupOptions.setRequired(false); options.addOption(groupOptions); // default label value final Option defaultLabelOption = new Option("dl", "default-label", true, "Specify the label to use for columns that are not identified by -l -g pairs. Default value is zero."); groupOptions.setArgName("double-value"); groupOptions.setRequired(false); options.addOption(defaultLabelOption); // parse the command line arguments CommandLine line = null; double defaultLabelValue = 0; try { // create the command line parser final CommandLineParser parser = new BasicParser(); line = parser.parse(options, args, true); if ((line.hasOption("l") && !line.hasOption("g")) || (line.hasOption("g") && !line.hasOption("l"))) { System.err.println("Options -label and -group must be used together."); System.exit(10); } if (line.hasOption("l") && line.getOptionValues("l").length != line.getOptionValues("g").length) { System.err.println("The number of -label and -group options must match exactly."); System.exit(10); } if (line.hasOption("dl")) { defaultLabelValue = Double.parseDouble(line.getOptionValue("dl")); } } catch (ParseException e) { System.err.println(e.getMessage()); usage(options); System.exit(1); } // print help and exit if (line.hasOption("h")) { usage(options); System.exit(0); } try { final Map<Double, Set<String>> labels = readLabelGroups(line.getOptionValues("l"), line.getOptionValues("g")); //labels convert(line.getOptionValue("i"), line.getOptionValue("o"), labels, defaultLabelValue); System.exit(0); } catch (FileNotFoundException e) { System.err.println("Error opening file: \n"); printGroups(line); } catch (IOException e) { System.err.println("An error occurred reading one of the group files:\n"); printGroups(line); } }
From source file:com.alibaba.rocketmq.tools.command.consumer.ConsumerProgressSubCommand.java
@Override public Options buildCommandlineOptions(Options options) { Option opt = new Option("g", "groupName", true, "consumer group name"); opt.setRequired(false); options.addOption(opt);// w w w . j a v a 2s.co m return options; }
From source file:com.cedarsoft.codegen.GeneratorCliSupport.java
@Nonnull protected Options buildOptions() { Options options = new Options(); {/*from ww w .j a v a 2 s. c om*/ Option option = new Option(OPTION_DESTINATION, "destination", true, "the output directory for the created classes"); option.setRequired(true); options.addOption(option); } { Option option = new Option(OPTION_RESOURCES_DESTINATION, "resources-destination", true, "the output directory for the created resources"); options.addOption(option); } { Option option = new Option(OPTION_TEST_DESTINATION, "test-destination", true, "the output directory for the created tests"); option.setRequired(true); options.addOption(option); } { Option option = new Option(OPTION_TEST_RESOURCES_DESTINATION, "test-resources-destination", true, "the output directory for the created test resources"); options.addOption(option); } options.addOption(HELP_OPTION, "help", false, "display this use message"); return options; }
From source file:li.strolch.runtime.main.MainStarter.java
private void configureOptions() { Options op = new Options(); Option rootPathOption = new Option("p", OPT_ROOT_PATH, true, "root path to strolch runtime"); rootPathOption.setOptionalArg(false); rootPathOption.setRequired(true); op.addOption(rootPathOption);/* www .j a va2 s . c o m*/ Option envOption = new Option("e", OPT_ENV, true, "environment to load from configuration file"); envOption.setOptionalArg(false); envOption.setRequired(true); op.addOption(envOption); this.options = op; }
From source file:datascript.emit.xml.XmlExtension.java
public void getOptions(org.apache.commons.cli.Options rdsOptions) { Option rdsOption; rdsOption = new Option("xml", false, "enables generation of a XML file of the syntaxtree"); rdsOption.setRequired(false); rdsOptions.addOption(rdsOption);/*from ww w . j a v a2 s . c o m*/ }
From source file:edu.cmu.tetrad.cli.AbstractAlgorithmCli.java
@Override public void setCommonRequiredOptions() { Option requiredOption = new Option("f", "data", true, "Data file."); requiredOption.setRequired(true); MAIN_OPTIONS.addOption(requiredOption); }
From source file:com.opengamma.financial.generator.AbstractPortfolioGeneratorTool.java
private Option required(final Option option) { option.setRequired(true); return option; }
From source file:net.orpiske.ssps.sdm.actions.Installer.java
@Override protected void processCommand(String[] args) { CommandLineParser parser = new PosixParser(); options = new Options(); options.addOption("h", "help", false, "prints the help"); options.addOption("g", "groupid", true, "package group id"); options.addOption("p", "package", true, "package name"); options.addOption("r", "repository", true, "the name of the repository to use"); options.addOption(null, "cleanup", false, "cleanup the work directory after finished"); options.addOption(null, "reinstall", false, "reinstall already installed packages"); options.addOption(null, "view", false, "only view the packages to be installed"); Option phasesOptions = OptionBuilder.withLongOpt("phases").create(); phasesOptions.setArgs(6);// www . j a va 2s. c o m phasesOptions.setRequired(false); phasesOptions.setDescription("the install phase(s) to run (implies --nodeps)"); options.addOption(phasesOptions); options.addOption(null, "nodeps", false, "does not install dependencies"); options.addOption("v", "version", true, "version"); try { cmdLine = parser.parse(options, args); } catch (ParseException e) { help(options, -1); } isHelp = cmdLine.hasOption("help"); reinstall = cmdLine.hasOption("reinstall"); cleanup = cmdLine.hasOption("cleanup"); view = cmdLine.hasOption("view"); packageName = cmdLine.getOptionValue('p'); if (packageName == null) { help(options, -1); } groupId = cmdLine.getOptionValue('g'); version = cmdLine.getOptionValue('v'); phases = cmdLine.getOptionValues("phases"); if (phases != null && phases.length > 0) { nodeps = true; } else { nodeps = cmdLine.hasOption("nodeps"); } repository = cmdLine.getOptionValue('r'); }
From source file:datascript.backend.xml.XmlExtension.java
public void getOptions(org.apache.commons.cli.Options rdsOptions) { org.apache.commons.cli.Option rdsOption; rdsOption = new Option("xml", false, "enables generation of a XML file of the syntaxtree"); rdsOption.setRequired(false); rdsOptions.addOption(rdsOption);//from w w w.j a v a 2 s. c o m }