List of usage examples for org.apache.commons.cli OptionBuilder isRequired
public static OptionBuilder isRequired()
From source file:edu.harvard.med.iccbl.screensaver.io.screens.MedicinalCompoundsStudyCreator.java
public static void main(String[] args) { final MedicinalCompoundsStudyCreator app = new MedicinalCompoundsStudyCreator(args); app.addCommandLineOption(OptionBuilder.isRequired().hasArg().withArgName("workbook file") .withLongOpt("input-file").create("f")); app.processOptions(true, true);/* www.j a v a 2s. c om*/ app.run(); }
From source file:com.maxl.java.aips2sqlite.Aips2Sqlite.java
/** * Adds an option into the command line parser * /*from w w w .j a v a 2 s . c o m*/ * @param optionName - the option name * @param description - option descriptiuon * @param hasValue - if set to true, --option=value, otherwise, --option is a boolean * @param isMandatory - if set to true, the option must be provided. */ @SuppressWarnings("static-access") static void addOption(Options opts, String optionName, String description, boolean hasValue, boolean isMandatory) { OptionBuilder opt = OptionBuilder.withLongOpt(optionName); opt = opt.withDescription(description); if (hasValue) opt = opt.hasArg(); if (isMandatory) opt = opt.isRequired(); opts.addOption(opt.create()); }
From source file:com.indeed.imhotep.index.builder.util.EasyIndexBuilderOptions.java
@Override protected void setup() { description = "builds index shard for specified time range\n" + "start and end must be in yyyy-MM-dd HH:mm:ss format, but mins and secs will be truncated.\n" + "DO quote start and end"; examples = "-o /var/ramses/tmp/indexname -r odin:9091 --start \"2009-06-16 09:00:00\" --end \"2009-06-16 12:00:00\""; options.addOption(OptionBuilder.isRequired().withArgName("YYYY-MM-DD HH:MM:SS") .withDescription("start time for processing, can be milliseconds").hasArg().withLongOpt("start") .create());//from w ww. j ava 2s . co m options.addOption(OptionBuilder.isRequired().withArgName("YYYY-MM-DD HH:MM:SS") .withDescription("end time for processing, can be milliseconds").hasArg().withLongOpt("end") .create()); options.addOption(OptionBuilder.isRequired().withArgName("dir").withDescription("output directory").hasArg() .withLongOpt("output").create("o")); options.addOption(OptionBuilder.withArgName("args").withDescription("additional arguments").hasArg() .withLongOpt("extra").create("e")); options.addOption( OptionBuilder.withDescription("clear this segment if it exists").withLongOpt("overwrite").create()); options.addOption( OptionBuilder.withDescription("exit without error if logs exist").withLongOpt("skip").create()); }
From source file:com.keriati.pqrcode.PQOptions.java
public void parse(String[] args) { Options options = new Options(); options.addOption(//www. j a v a 2 s . c o m OptionBuilder.withLongOpt("width").withDescription("Output file width in pixels. Default: 250") .hasArgs(1).withArgName("width").create("w")); options.addOption( OptionBuilder.withLongOpt("height").withDescription("Output file height in pixels. Default: 250") .hasArgs(1).withArgName("height").create("h")); options.addOption(OptionBuilder.isRequired().withLongOpt("output") .withDescription("Output file name. (required)").hasArgs(1).withArgName("output").create("o")); options.addOption(OptionBuilder.isRequired().withLongOpt("data") .withDescription("Data to encode. (required)").hasArgs(1).withArgName("data").create("d")); options.addOption(OptionBuilder.withLongOpt("format") .withDescription("Image format. Supported values: JPEG, PNG, GIF, BMP, WBMP. Default is: PNG") .hasArgs(1).withArgName("format").create("f")); options.addOption(OptionBuilder.withLongOpt("quietZoneSize") .withDescription("White border size arround the QR Code. Default: 4.").hasArgs(1) .withArgName("quietZoneSize").create("q")); GnuParser parser = new GnuParser(); try { CommandLine line = parser.parse(options, args); width = Integer.parseInt(line.getOptionValue("width", "250")); height = Integer.parseInt(line.getOptionValue("height", "250")); quietZoneSize = Integer.parseInt(line.getOptionValue("quietZoneSize", "4")); format = line.getOptionValue("format", "PNG"); if (line.hasOption("output")) { output = line.getOptionValue("output"); } if (line.hasOption("data")) { data = line.getOptionValue("data"); } } catch (ParseException exp) { System.out.println("ERROR:" + exp.getMessage()); } if (output == null || data == null) { HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("java -jar PQRCode.jar", options); System.exit(0); } }
From source file:fr.smartcontext.yatte.context.cli.DefaultOptionsProvider.java
/** * {@inheritDoc}//w w w . j a v a 2 s .c o m * @see fr.smartcontext.yatte.context.cli.CLIOptionsProvider#getOptions() */ @Override public Options getOptions() { Options options = new Options(); OptionBuilder.withLongOpt(ApplicationParametersConstants.PROPERTIES_PATH_OPTION_LONG_NAME); OptionBuilder.withDescription(ApplicationParametersConstants.PROPERTIES_PATH_OPTION_DESCRIPTION); OptionBuilder.hasArg(); OptionBuilder.withArgName(ApplicationParametersConstants.PROPERTIES_PATH_OPTION_ARGUMENT_NAME); options.addOption(OptionBuilder.create(ApplicationParametersConstants.PROPERTIES_PATH_OPTION_NAME)); OptionBuilder.withLongOpt(ApplicationParametersConstants.OUTPUT_OPTION_LONG_NAME); OptionBuilder.withDescription(ApplicationParametersConstants.OUTPUT_OPTION_DESCRIPTION); OptionBuilder.hasArg(); OptionBuilder.withArgName(ApplicationParametersConstants.OUTPUT_OPTION_ARGUMENT_NAME); OptionBuilder.isRequired(); options.addOption(OptionBuilder.create(ApplicationParametersConstants.OUTPUT_OPTION_NAME)); OptionBuilder.withLongOpt(ApplicationParametersConstants.TEMPLATE_OPTION_LONG_NAME); OptionBuilder.withDescription(ApplicationParametersConstants.TEMPLATE_OPTION_DESCRIPTION); OptionBuilder.hasArg(); OptionBuilder.withArgName(ApplicationParametersConstants.TEMPLATE_OPTION_ARGUMENT_NAME); OptionBuilder.isRequired(); options.addOption(OptionBuilder.create(ApplicationParametersConstants.TEMPLATE_OPTION_NAME)); return options; }
From source file:eu.stratosphere.meteor.client.CLClient.java
@SuppressWarnings("static-access") private void initOptions() { this.options.addOption(OptionBuilder.isRequired().withArgName("file").hasArg(true) .withDescription("Executes the given script").create("f")); this.options.addOption(OptionBuilder.withArgName("config").hasArg(true) .withDescription("Uses the given configuration").withLongOpt("configDir").create()); this.options.addOption(OptionBuilder.withArgName("server").hasArg(true) .withDescription("Uses the specified server").withLongOpt("server").create()); this.options.addOption(OptionBuilder.withArgName("port").hasArg(true) .withDescription("Uses the specified port").withLongOpt("port").create()); this.options.addOption(OptionBuilder.withArgName("updateTime").hasArg(true) .withDescription("Checks with the given update time for the current status") .withLongOpt("updateTime").create()); this.options.addOption(OptionBuilder.hasArg(false) .withDescription("Waits until the script terminates on the server").withLongOpt("wait").create()); }
From source file:net.nicholaswilliams.java.licensing.licensor.interfaces.cli.spi.CliOptionsBuilder.java
public CliOptionsBuilder isRequired() { OptionBuilder.isRequired(); return this; }
From source file:de.clusteval.data.dataset.generator.CassiniDataSetGenerator.java
@Override protected Options getOptions() { Options options = new Options(); OptionBuilder.withArgName("n"); OptionBuilder.isRequired(); OptionBuilder.hasArg();/*w w w. j a va 2s . com*/ OptionBuilder.withDescription("The number of points."); Option option = OptionBuilder.create("n"); options.addOption(option); return options; }
From source file:de.clusteval.data.dataset.generator.CircleDataSetGenerator.java
@Override protected Options getOptions() { Options options = new Options(); OptionBuilder.withArgName("n"); OptionBuilder.isRequired(); OptionBuilder.hasArg();/* www . j a v a 2 s .co m*/ OptionBuilder.withDescription("The number of points."); Option option = OptionBuilder.create("n"); options.addOption(option); OptionBuilder.withArgName("d"); OptionBuilder.hasArg(); OptionBuilder.withDescription("The number of dimensions."); option = OptionBuilder.create("d"); options.addOption(option); return options; }
From source file:de.clusteval.data.dataset.generator.SpiralsDataSetGenerator.java
@Override protected Options getOptions() { Options options = new Options(); OptionBuilder.withArgName("n"); OptionBuilder.isRequired(); OptionBuilder.hasArg();//from w ww . j a va 2 s . co m OptionBuilder.withDescription("The number of points."); Option option = OptionBuilder.create("n"); options.addOption(option); OptionBuilder.withArgName("c"); OptionBuilder.hasArg(); OptionBuilder.withDescription("The number of cycles."); option = OptionBuilder.create("c"); options.addOption(option); OptionBuilder.withArgName("sd"); OptionBuilder.hasArg(); OptionBuilder.withDescription("The standard deviation."); option = OptionBuilder.create("sd"); options.addOption(option); return options; }