List of usage examples for org.apache.commons.cli OptionBuilder isRequired
public static OptionBuilder isRequired()
From source file:de.clusteval.data.dataset.generator.HyperCubeCornersDataSetGenerator.java
@Override protected Options getOptions() { Options options = new Options(); OptionBuilder.withArgName("n"); OptionBuilder.isRequired(); OptionBuilder.hasArg();//from w ww .j a v a 2 s .c om 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); OptionBuilder.withArgName("sd"); OptionBuilder.hasArg(); OptionBuilder.withDescription("The standard deviation."); option = OptionBuilder.create("sd"); options.addOption(option); return options; }
From source file:de.clusteval.data.dataset.generator.QiuJoeCovarianceClusterDataSetGenerator.java
@Override protected Options getOptions() { Options options = new Options(); OptionBuilder.withArgName("n"); OptionBuilder.isRequired(); OptionBuilder.hasArg();/* www .ja v a 2 s. co m*/ OptionBuilder.withDescription("The number of points."); Option option = OptionBuilder.create("n"); options.addOption(option); OptionBuilder.withDescription("Make the cluster sizes different."); option = OptionBuilder.create("sizes"); options.addOption(option); OptionBuilder.withArgName("k"); OptionBuilder.isRequired(); OptionBuilder.hasArg(); OptionBuilder.withDescription("The number of clusters."); option = OptionBuilder.create("k"); options.addOption(option); OptionBuilder.withArgName("noisyfeatures"); OptionBuilder.isRequired(); OptionBuilder.hasArg(); OptionBuilder.withDescription("The number of noisy features."); option = OptionBuilder.create("dn"); options.addOption(option); OptionBuilder.withArgName("features"); OptionBuilder.isRequired(); OptionBuilder.hasArg(); OptionBuilder.withDescription("The number of non-noisy (clustered/separated) features."); option = OptionBuilder.create("d"); options.addOption(option); OptionBuilder.withArgName("clusterSeparation"); OptionBuilder.isRequired(); OptionBuilder.hasArg(); OptionBuilder.withDescription("The cluster separation (between -1.0 and +1.0)."); option = OptionBuilder.create("s"); options.addOption(option); return options; }
From source file:jurbano.melodyshape.ui.ConsoleUIObserver.java
/** * Constructs a new {@code ConsoleUIObserver} according to some command line * arguments./*from w w w . j a va 2 s . c om*/ * * @param args * the command line arguments to configure the algorithm. */ @SuppressWarnings("static-access") public ConsoleUIObserver(String[] args) { this.args = args; this.qOpt = null; this.cOpt = null; this.aOpt = null; this.lOpt = false; this.hOpt = false; this.tOpt = Runtime.getRuntime().availableProcessors(); this.kOpt = Integer.MAX_VALUE; this.vOpt = 0; this.options = new Options(); // required arguments this.options.addOption(OptionBuilder.isRequired().hasArg().withArgName("file/dir") .withDescription("path to the query melody or melodies.").create("q")); this.options.addOption(OptionBuilder.isRequired().hasArg().withArgName("dir") .withDescription("path to the collection of documents.").create("c")); this.options.addOption(OptionBuilder.isRequired().hasArg().withArgName("name") .withDescription("algorithm to run:" + "\n- 2010-domain, 2010-pitchderiv, 2010-shape" + "\n- 2011-shape, 2011-pitch, 2011-time" + "\n- 2012-shapeh, 2012-shapel, 2012-shapeg, 2012-time, 2012-shapetime" + "\n- 2013-shapeh, 2013-time, 2013-shapetime" + "\n- 2014-shapeh, 2014-time, 2014-shapetime" + "\n- 2015-shapeh, 2015-time, 2015-shapetime") .create("a")); // optional arguments this.options.addOption(OptionBuilder .withDescription("show results in a single line (omits similarity scores).").create("l")); this.options.addOption(OptionBuilder.hasArg().withArgName("num") .withDescription("run a fixed number of threads.").create("t")); this.options.addOption(OptionBuilder.hasArg().withArgName("cutoff") .withDescription("number of documents to retrieve.").create("k")); this.options.addOption(OptionBuilder.withDescription("verbose, to stderr.").create("v")); this.options.addOption(OptionBuilder.withDescription("verbose a lot, to stderr.").create("vv")); this.options.addOption(OptionBuilder.withDescription("show this help message.").create("h")); this.options.addOption(OptionBuilder.withDescription("run with graphical user interface.").create("gui")); }
From source file:de.wpsverlinden.ufilan.Ufilan.java
private CommandLine initCli() throws ParseException { options = new Options(); options.addOption(OptionBuilder.isRequired().hasArg() .withDescription("action to perform (histogram_text, histogram_img, map, type, size, entropy)") .create("a")); options.addOption(OptionBuilder.withArgName("file").hasArg() .withDescription("path of the input file. If null, stdin is used").create("if")); options.addOption(OptionBuilder.withArgName("file").hasArg() .withDescription("path of the output file. If null, stdout is used").create("of")); options.addOption(OptionBuilder.withArgName("byte").hasArg() .withDescription("chunk size in bytes used for input parsing. Default value: 1 byte").create("c")); options.addOption(OptionBuilder.withArgName("byte").hasArg() .withDescription("skips the given number of bytes start parsing. Default value: 0 byte") .create("s")); CommandLineParser parser = new PosixParser(); return parser.parse(options, args); }
From source file:be.svlandeg.diffany.console.DiffanyOptions.java
/** * Define the options specifying necessary arguments for the Diffany algorithms *//*from w w w . java 2s .c o m*/ private Set<Option> getAllParameters() { Set<Option> allParameters = new HashSet<Option>(); OptionBuilder.withArgName("dir"); OptionBuilder.withLongOpt("inputDir"); OptionBuilder.hasArgs(1); OptionBuilder.isRequired(); OptionBuilder .withDescription("the input directory containing the reference and condition-specific networks"); allParameters.add(OptionBuilder.create(inputShort)); OptionBuilder.withArgName("dir"); OptionBuilder.withLongOpt("outputDir"); OptionBuilder.hasArgs(1); OptionBuilder.isRequired(); OptionBuilder.withDescription( "the output directory which will contain the generated differential/consensus networks"); allParameters.add(OptionBuilder.create(outputShort)); String defaultRunDiffString = defaultRunDiff ? "yes" : "no"; OptionBuilder.withLongOpt("differential"); OptionBuilder.hasArgs(1); OptionBuilder.withDescription("whether or not to calculate differential networks: yes or no (default=" + defaultRunDiffString + ")"); allParameters.add(OptionBuilder.create(runDiff)); String defaultRunConsString = defaultRunCons ? "yes" : "no"; ; OptionBuilder.withLongOpt("consensus"); OptionBuilder.hasArgs(1); OptionBuilder.withDescription( "whether or not to calculate consensus networks: yes or no (default=" + defaultRunConsString + ")"); allParameters.add(OptionBuilder.create(runCons)); OptionBuilder.withLongOpt("outputID"); OptionBuilder.hasArgs(1); OptionBuilder.withDescription("the first ID that will be used for the generated networks"); allParameters.add(OptionBuilder.create(nextID)); OptionBuilder.withLongOpt("confidence"); OptionBuilder.hasArgs(1); OptionBuilder.withDescription( "the minimum confidence threshold for output edges, as an integer or double (default=0.0)"); allParameters.add(OptionBuilder.create(cutoffShort)); String defaultMinOperatorString = defaultMinOperator ? "min" : "max"; OptionBuilder.withLongOpt("operator"); OptionBuilder.hasArgs(1); OptionBuilder.withDescription("the operator used to create consensus edges: min or max (default=" + defaultMinOperatorString + ")"); allParameters.add(OptionBuilder.create(operatorShort)); String defaultModeString = defaultModePairwise ? "pairwise" : "all"; OptionBuilder.withLongOpt("mode"); OptionBuilder.hasArgs(1); OptionBuilder .withDescription("the mode of comparison: pairwise or all (default=" + defaultModeString + ")"); allParameters.add(OptionBuilder.create(modeShort)); String defaultHeaderString = defaultReadHeader ? "yes" : "no"; OptionBuilder.withLongOpt("skipHeader"); OptionBuilder.hasArgs(1); OptionBuilder.withDescription( "whether or not to skip the first line (header) in the network .txt files (default=" + defaultHeaderString + ")"); allParameters.add(OptionBuilder.create(headerShort)); return allParameters; }
From source file:eu.crydee.alignment.aligner.MetricsP.java
static private void parseArguments(String[] args) { Options shortCircuitOptions = new Options(); shortCircuitOptions// w w w .j ava 2 s . c o m .addOption(OptionBuilder.withLongOpt("help").withDescription("Print this message.").create('h')); shortCircuitOptions .addOption(OptionBuilder.withLongOpt("version").withDescription("Print the version.").create('v')); Options options = new Options(); options.addOption(OptionBuilder.isRequired().withLongOpt("corpus").hasArg().withArgName("folder-path") .withDescription("Path to the britannica corpus.").create('c')); options.addOption(OptionBuilder.isRequired().withLongOpt("whitelist-path").hasArg().withArgName("file-path") .withDescription("Path to the whitelist of files to test. One " + "city per line.").create('w')); try { CommandLineParser parser = new PosixParser(); CommandLine cmd = parser.parse(shortCircuitOptions, args, true); if (cmd.hasOption('h')) { HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("aligner", options, true); System.exit(0); } if (cmd.hasOption('v')) { System.out.println("aligner v1.0.0-SNAPSHOT"); System.exit(0); } cmd = parser.parse(options, args); WHITELIST_FILE_PATH = cmd.getOptionValue('w'); CORPUS_PATH = cmd.getOptionValue('c'); } catch (ParseException ex) { System.err.println("The CLI args could not be parsed."); System.err.println("The error message was:"); System.err.println(" " + ex.getMessage()); System.exit(1); } }
From source file:com.ehi.carshare.Main.java
@SuppressWarnings("static-access") private static Option buildOption(String argName, String longOpt, String description) { return OptionBuilder.isRequired().hasArg(true).withLongOpt(longOpt).withDescription(description) .create(argName);/*from w ww . ja v a 2 s. c o m*/ }
From source file:eu.crydee.alignment.aligner.BritannicaP.java
static private void parseArguments(String[] args) { Options shortCircuitOptions = new Options(); shortCircuitOptions//from w ww. j a v a 2 s.c o m .addOption(OptionBuilder.withLongOpt("help").withDescription("Print this message.").create('h')); shortCircuitOptions .addOption(OptionBuilder.withLongOpt("version").withDescription("Print the version.").create('v')); Options options = new Options(); options.addOption(OptionBuilder.isRequired().withLongOpt("corpus-path").hasArg().withArgName("folder-path") .withDescription("Path to the Britannica corpus.").create('c')); options.addOption( OptionBuilder.isRequired().withLongOpt("annotations-path").hasArg().withArgName("folder-path") .withDescription("Path to the test folder of the annotations.").create('a')); try { CommandLineParser parser = new PosixParser(); CommandLine cmd = parser.parse(shortCircuitOptions, args, true); if (cmd.hasOption('h')) { HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("britannica", options, true); System.exit(0); } if (cmd.hasOption('v')) { System.out.println("britannica-aligner v1.0.0-SNAPSHOT"); System.exit(0); } cmd = parser.parse(options, args); CORPUS = cmd.getOptionValue('c'); ANNS = cmd.getOptionValue('a'); } catch (ParseException ex) { System.err.println("The CLI args could not be parsed."); System.err.println("The error message was:"); System.err.println(" " + ex.getMessage()); System.exit(1); } }
From source file:de.clusteval.data.randomizer.DataRandomizer.java
/** * Adds the default options of dataset generators to the given Options * attribute//w ww . j ava 2s . co m * * @param options * The existing Options attribute, holding already the options of * the actual generator implementation. */ private void addDefaultOptions(final Options options) { OptionBuilder.withArgName("dataConfig"); OptionBuilder.isRequired(); OptionBuilder.hasArg(); OptionBuilder.withDescription("The name of the data configuration to randomize"); Option option = OptionBuilder.create("dataConfig"); options.addOption(option); }
From source file:de.clusteval.data.dataset.generator.DataSetGenerator.java
/** * Adds the default options of dataset generators to the given Options * attribute// w ww .jav a 2s. co m * * @param options * The existing Options attribute, holding already the options of * the actual generator implementation. */ private void addDefaultOptions(final Options options) { OptionBuilder.withArgName("folderName"); OptionBuilder.isRequired(); OptionBuilder.hasArg(); OptionBuilder.withDescription("The name of the folder to store this dataset in."); Option option = OptionBuilder.create("folderName"); options.addOption(option); OptionBuilder.withArgName("fileName"); OptionBuilder.isRequired(); OptionBuilder.hasArg(); OptionBuilder.withDescription("The name of the dataset file to generate."); option = OptionBuilder.create("fileName"); options.addOption(option); OptionBuilder.withArgName("alias"); OptionBuilder.isRequired(); OptionBuilder.hasArg(); OptionBuilder.withDescription("The alias of the data set."); option = OptionBuilder.create("alias"); options.addOption(option); }