List of usage examples for org.apache.commons.cli OptionBuilder withDescription
public static OptionBuilder withDescription(String newDescription)
From source file:org.apache.blur.shell.AddColumnDefinitionCommand.java
@SuppressWarnings("static-access") private static CommandLine parse(String[] otherArgs, Writer out) { Options options = new Options(); options.addOption(OptionBuilder.withArgName("sub column name").hasArg() .withDescription("The sub column name of the new column definition.").create("s")); options.addOption(OptionBuilder .withDescription(// ww w. j av a2 s. com "Should the column definition be definied as a field less indexing column definition.") .create("F")); options.addOption(OptionBuilder.withArgName("name value").hasArgs(2) .withDescription("Sets the properties for this column definition.").create("p")); options.addOption(OptionBuilder .withDescription("Should the column definition be definied as a sortable column definition.") .create("S")); options.addOption(OptionBuilder .withDescription("Should the column definition be definied as a multi value column definition.") .create("M")); CommandLineParser parser = new PosixParser(); CommandLine cmd = null; try { cmd = parser.parse(options, otherArgs); } catch (ParseException e) { HelpFormatter formatter = new HelpFormatter(); PrintWriter pw = new PrintWriter(out, true); formatter.printHelp(pw, HelpFormatter.DEFAULT_WIDTH, "definecolumn", null, options, HelpFormatter.DEFAULT_LEFT_PAD, HelpFormatter.DEFAULT_DESC_PAD, null, false); return null; } return cmd; }
From source file:org.apache.blur.shell.CopyTableCommand.java
@SuppressWarnings("static-access") public static CommandLine parse(String[] otherArgs, Writer out) { Options options = new Options(); options.addOption(OptionBuilder.isRequired().hasArg().withArgName("tablename") .withDescription("* Source table name.").create("src")); options.addOption(OptionBuilder.isRequired().hasArg().withArgName("tablename") .withDescription("* Target table name.").create("dest")); options.addOption(OptionBuilder.isRequired().hasArg().withArgName("cluster") .withDescription("* Target cluster for new table.").create("c")); options.addOption(OptionBuilder.hasArg().isRequired().withArgName("uri") .withDescription("The location of the target table. (Example hdfs://namenode/blur/tables/table)") .create("l")); options.addOption(OptionBuilder.withDescription("Displays help for this command.").create("h")); CommandLineParser parser = new PosixParser(); CommandLine cmd = null;/* w w w . ja v a 2 s . c om*/ try { cmd = parser.parse(options, otherArgs); if (cmd.hasOption("h")) { HelpFormatter formatter = new HelpFormatter(); PrintWriter pw = new PrintWriter(out, true); formatter.printHelp(pw, HelpFormatter.DEFAULT_WIDTH, "copy", null, options, HelpFormatter.DEFAULT_LEFT_PAD, HelpFormatter.DEFAULT_DESC_PAD, null, false); return null; } } catch (ParseException e) { HelpFormatter formatter = new HelpFormatter(); PrintWriter pw = new PrintWriter(out, true); formatter.printHelp(pw, HelpFormatter.DEFAULT_WIDTH, "copy", null, options, HelpFormatter.DEFAULT_LEFT_PAD, HelpFormatter.DEFAULT_DESC_PAD, null, false); return null; } return cmd; }
From source file:org.apache.blur.shell.CreateTableCommandHelper.java
@SuppressWarnings("static-access") public static CommandLine parse(String[] otherArgs, Writer out) { Options options = new Options(); options.addOption(OptionBuilder .withDescription("Disables the blockcache for this table. (Enabled by default)").create("b")); options.addOption(OptionBuilder/* w ww . jav a 2 s .c o m*/ .withDescription("Disables the table when it is created. (Enabled by default)").create("d")); options.addOption(OptionBuilder.withDescription("Enabled strict types on a table. (Disabled by default)") .create("s")); options.addOption( OptionBuilder.withDescription("Enables a read only table. (Disabled by default)").create("r")); options.addOption(OptionBuilder.isRequired().hasArg().withArgName("tablename") .withDescription("* The table name.").create("t")); options.addOption(OptionBuilder.isRequired().hasArg().withArgName("shard count") .withDescription("* The number of shards in the table.").create("c")); options.addOption(OptionBuilder.hasArg().withArgName("uri") .withDescription("The location of the table. (Example hdfs://namenode/blur/tables/table)") .create("l")); options.addOption(OptionBuilder.withArgName("filetype").hasOptionalArgs().withDescription( "Sets the filetypes (.tim, .tis, .doc, etc.) to be cached in the block cache. (All by default)") .create("B")); options.addOption(OptionBuilder.withDescription( "If table is not strict, disables the missing field, fieldless indexing. (Enabled by default)") .create("mfi")); options.addOption(OptionBuilder.withArgName("field type").hasArg() .withDescription( "If table is not strict, sets the field type for the missing field. (text by default)") .create("mft")); options.addOption(OptionBuilder.withArgName("name value").hasArgs(2) .withDescription("If table is not strict, sets the properties for the missing field.") .create("mfp")); options.addOption(OptionBuilder.withArgName("name value").hasArgs(2) .withDescription("Sets the properties for this table descriptor.").create("p")); options.addOption(OptionBuilder.withArgName("column name*").hasArgs() .withDescription( "Sets what columns to pre cache during warmup. (By default all columns are cached)") .create("P")); options.addOption(OptionBuilder.withArgName("classname").hasArg().withDescription( "Sets the similarity class for the table. (By org.apache.blur.lucene.search.FairSimilarity is used)") .create("S")); options.addOption(OptionBuilder.withDescription("Displays help for this command.").create("h")); CommandLineParser parser = new PosixParser(); CommandLine cmd = null; try { cmd = parser.parse(options, otherArgs); if (cmd.hasOption("h")) { HelpFormatter formatter = new HelpFormatter(); PrintWriter pw = new PrintWriter(out, true); formatter.printHelp(pw, HelpFormatter.DEFAULT_WIDTH, "create", null, options, HelpFormatter.DEFAULT_LEFT_PAD, HelpFormatter.DEFAULT_DESC_PAD, null, false); return null; } } catch (ParseException e) { HelpFormatter formatter = new HelpFormatter(); PrintWriter pw = new PrintWriter(out, true); formatter.printHelp(pw, HelpFormatter.DEFAULT_WIDTH, "create", null, options, HelpFormatter.DEFAULT_LEFT_PAD, HelpFormatter.DEFAULT_DESC_PAD, null, false); return null; } return cmd; }
From source file:org.apache.blur.shell.DiscoverFileBufferSizeUtil.java
@SuppressWarnings("static-access") public CommandLine parse(String[] otherArgs, Writer out) { Options options = new Options(); options.addOption(OptionBuilder.withDescription("The path to write temp files.").hasArg().isRequired(true) .create("p")); options.addOption(OptionBuilder.withDescription("The size of the temp files (1 GB by default).").hasArg() .create("s")); options.addOption(OptionBuilder.withDescription("Number of cycles of the test. (10 by default)").hasArg() .create("S")); options.addOption(/* w ww . j ava 2 s .c o m*/ OptionBuilder.withDescription("Number of warmup cycles. (3 by default)").hasArg().create("W")); options.addOption(OptionBuilder.withDescription("Min buffer size power of 2 (12 by default 4KB)").hasArg() .create("n")); options.addOption(OptionBuilder.withDescription("Max buffer size power of 2 (19 by default 512KB)").hasArg() .create("x")); options.addOption( OptionBuilder.withDescription("Number of random read samples during read test. (1000 by default)") .hasArg().create("r")); options.addOption(OptionBuilder.withDescription("Displays help for this command.").create("h")); CommandLineParser parser = new PosixParser(); CommandLine cmd = null; try { cmd = parser.parse(options, otherArgs); if (cmd.hasOption("h")) { HelpFormatter formatter = new HelpFormatter(); PrintWriter pw = new PrintWriter(out, true); formatter.printHelp(pw, HelpFormatter.DEFAULT_WIDTH, name(), null, options, HelpFormatter.DEFAULT_LEFT_PAD, HelpFormatter.DEFAULT_DESC_PAD, null, false); return null; } } catch (ParseException e) { HelpFormatter formatter = new HelpFormatter(); PrintWriter pw = new PrintWriter(out, true); formatter.printHelp(pw, HelpFormatter.DEFAULT_WIDTH, name(), null, options, HelpFormatter.DEFAULT_LEFT_PAD, HelpFormatter.DEFAULT_DESC_PAD, null, false); return null; } return cmd; }
From source file:org.apache.blur.shell.QueryCommandHelper.java
@SuppressWarnings("static-access") public static CommandLine parse(String[] otherArgs, Writer out, String usage) { Options options = new Options(); options.addOption(OptionBuilder.hasArgs().withDescription("* Query string.").isRequired().create(QUERY)); options.addOption(OptionBuilder.withDescription("Disables row query. (Enabled by default)") .create(DISABLE_ROW_QUERY)); options.addOption(OptionBuilder.hasArg().withArgName(SCORE_TYPE) .withDescription("Specify the scoring type.").create(SCORE_TYPE)); options.addOption(OptionBuilder.hasArgs().withArgName(ROW_FILTER).withDescription("Specify row filter.") .create(ROW_FILTER));/*ww w .j av a2 s .co m*/ options.addOption(OptionBuilder.hasArgs().withArgName(RECORD_FILTER) .withDescription("Specify record filter.").create(RECORD_FILTER)); options.addOption(OptionBuilder.hasArg().withArgName(START) .withDescription("Specify the starting position (paging).").create(START)); options.addOption(OptionBuilder.hasArg().withArgName(FETCH) .withDescription("Specify the number of elements to fetch in a single page.").create(FETCH)); options.addOption(OptionBuilder.hasArg().withArgName(MAX_QUERY_TIME) .withDescription("Specify the maximum amount of time to allow query to execute.") .create(MAX_QUERY_TIME)); options.addOption(OptionBuilder.hasArg().withArgName(MINIMUM_NUMBER_OF_RESULTS) .withDescription("Specify the minimum number of results required before returning from query.") .create(MINIMUM_NUMBER_OF_RESULTS)); options.addOption(OptionBuilder.hasArg().withArgName(ROW_ID) .withDescription( "Specify the rowId to execute the query against (this reduces the spray to other shards).") .create(ROW_ID)); options.addOption(OptionBuilder.withArgName(FACET).hasArgs() .withDescription("Specify facet to be executed with this query.").create(FACET)); options.addOption(OptionBuilder.withArgName(SORT).hasArgs() .withDescription("Specify a sort to be applied to this query <family> <column> [<reverse>].") .create(SORT)); options.addOption(OptionBuilder.withDescription("Displays help for this command.").create("h")); options.addOption(OptionBuilder.withArgName(WIDTH).hasArgs() .withDescription("Specify max column width for display.").create(WIDTH)); CommandLineParser parser = new PosixParser(); CommandLine cmd = null; try { cmd = parser.parse(options, otherArgs); if (cmd.hasOption("h")) { HelpFormatter formatter = new HelpFormatter(); PrintWriter pw = new PrintWriter(out, true); formatter.printHelp(pw, HelpFormatter.DEFAULT_WIDTH, usage, null, options, HelpFormatter.DEFAULT_LEFT_PAD, HelpFormatter.DEFAULT_DESC_PAD, null, false); return null; } } catch (ParseException e) { HelpFormatter formatter = new HelpFormatter(); PrintWriter pw = new PrintWriter(out, true); formatter.printHelp(pw, HelpFormatter.DEFAULT_WIDTH, usage, null, options, HelpFormatter.DEFAULT_LEFT_PAD, HelpFormatter.DEFAULT_DESC_PAD, null, false); return null; } return cmd; }
From source file:org.apache.blur.shell.TermsDataCommand.java
@SuppressWarnings("static-access") private static CommandLine parse(String[] otherArgs, Writer out) { Options options = new Options(); options.addOption(OptionBuilder.withArgName("startwith").hasArg() .withDescription("The value to start with.").create("s")); options.addOption(OptionBuilder.withArgName("size").hasArg() .withDescription("The number of terms to return.").create("n")); options.addOption(OptionBuilder.withDescription("Get the frequency of each term.").create("F")); CommandLineParser parser = new PosixParser(); CommandLine cmd = null;//from w w w .j a v a 2 s . c o m try { cmd = parser.parse(options, otherArgs); } catch (ParseException e) { HelpFormatter formatter = new HelpFormatter(); PrintWriter pw = new PrintWriter(out, true); formatter.printHelp(pw, HelpFormatter.DEFAULT_WIDTH, "terms", null, options, HelpFormatter.DEFAULT_LEFT_PAD, HelpFormatter.DEFAULT_DESC_PAD, null, false); return null; } return cmd; }
From source file:org.apache.commons.jci.examples.commandline.CommandlineCompiler.java
public static void main(String[] args) throws Exception { final Options options = new Options(); options.addOption(OptionBuilder.withArgName("a.jar:b.jar").hasArg().withValueSeparator(':') .withDescription("Specify where to find user class files").create("classpath")); options.addOption(OptionBuilder.withArgName("release").hasArg() .withDescription("Provide source compatibility with specified release").create("source")); options.addOption(OptionBuilder.withArgName("release").hasArg() .withDescription("Generate class files for specific VM version").create("target")); options.addOption(OptionBuilder.withArgName("path").hasArg() .withDescription("Specify where to find input source files").create("sourcepath")); options.addOption(OptionBuilder.withArgName("directory").hasArg() .withDescription("Specify where to place generated class files").create("d")); options.addOption(OptionBuilder.withArgName("num").hasArg() .withDescription("Stop compilation after these number of errors").create("Xmaxerrs")); options.addOption(OptionBuilder.withArgName("num").hasArg() .withDescription("Stop compilation after these number of warning").create("Xmaxwarns")); options.addOption(OptionBuilder.withDescription("Generate no warnings").create("nowarn")); // final HelpFormatter formatter = new HelpFormatter(); // formatter.printHelp("jci", options); final CommandLineParser parser = new GnuParser(); final CommandLine cmd = parser.parse(options, args, true); ClassLoader classloader = CommandlineCompiler.class.getClassLoader(); File sourcepath = new File("."); File targetpath = new File("."); int maxerrs = 10; int maxwarns = 10; final boolean nowarn = cmd.hasOption("nowarn"); final JavaCompiler compiler = new JavaCompilerFactory().createCompiler("eclipse"); final JavaCompilerSettings settings = compiler.createDefaultSettings(); for (Iterator it = cmd.iterator(); it.hasNext();) { final Option option = (Option) it.next(); if ("classpath".equals(option.getOpt())) { final String[] values = option.getValues(); final URL[] urls = new URL[values.length]; for (int i = 0; i < urls.length; i++) { urls[i] = new File(values[i]).toURL(); }// ww w . j av a 2s. com classloader = new URLClassLoader(urls); } else if ("source".equals(option.getOpt())) { settings.setSourceVersion(option.getValue()); } else if ("target".equals(option.getOpt())) { settings.setTargetVersion(option.getValue()); } else if ("sourcepath".equals(option.getOpt())) { sourcepath = new File(option.getValue()); } else if ("d".equals(option.getOpt())) { targetpath = new File(option.getValue()); } else if ("Xmaxerrs".equals(option.getOpt())) { maxerrs = Integer.parseInt(option.getValue()); } else if ("Xmaxwarns".equals(option.getOpt())) { maxwarns = Integer.parseInt(option.getValue()); } } final ResourceReader reader = new FileResourceReader(sourcepath); final ResourceStore store = new FileResourceStore(targetpath); final int maxErrors = maxerrs; final int maxWarnings = maxwarns; compiler.setCompilationProblemHandler(new CompilationProblemHandler() { int errors = 0; int warnings = 0; public boolean handle(final CompilationProblem pProblem) { if (pProblem.isError()) { System.err.println(pProblem); errors++; if (errors >= maxErrors) { return false; } } else { if (!nowarn) { System.err.println(pProblem); } warnings++; if (warnings >= maxWarnings) { return false; } } return true; } }); final String[] resource = cmd.getArgs(); for (int i = 0; i < resource.length; i++) { System.out.println("compiling " + resource[i]); } final CompilationResult result = compiler.compile(resource, reader, store, classloader); System.out.println(result.getErrors().length + " errors"); System.out.println(result.getWarnings().length + " warnings"); }
From source file:org.apache.ctakes.ytex.kernel.evaluator.CorpusKernelEvaluatorImpl.java
@SuppressWarnings("static-access") private static Options initOptions() { Options options = new Options(); options.addOption(OptionBuilder.withArgName("classpath*:simSvcBeanRefContext.xml").hasArg() .withDescription("use specified beanRefContext.xml, default classpath*:simSvcBeanRefContext.xml") .create("beanref")); options.addOption(OptionBuilder.withArgName("kernelApplicationContext").hasArg() .withDescription("use specified applicationContext, default kernelApplicationContext") .create("appctx")); options.addOption(OptionBuilder.withArgName("beans-corpus.xml").hasArg() .withDescription("use specified beans.xml, no default. This file is typically required.") .create("beans")); options.addOption(OptionBuilder.withArgName("yes/no").hasArg() .withDescription("should test instances be evaluated? default no.").create("evalTest")); options.addOption(OptionBuilder.withArgName("instanceMap.obj").hasArg().withDescription( "load instanceMap from file system instead of from db. Use after storing instance map. If not specified will attempt to load from db.") .create("loadInstanceMap")); options.addOption(OptionBuilder.withDescription("for parallelization, split the instances into mod slices") .hasArg().create("mod")); options.addOption(OptionBuilder.withDescription( "for parallelization, parameter that determines which slice we work on. If this is not specified, nMod threads will be started to evaluate all slices in parallel.") .hasArg().create("slice")); options.addOption(new Option("help", "print this message")); return options; }
From source file:org.apache.ctakes.ytex.KernelLauncher.java
private static Options initOptions() { Option oStoreInstanceMap = OptionBuilder.withArgName("instanceMap.obj").hasArg() .withDescription("store the instanceMap. Use prior to running the kernel evaluations in parallel.") .create("storeInstanceMap"); Option oEvaluateKernel = OptionBuilder.withDescription( "evaluate kernel specified in application context on the instances. If instanceMap is specified, load instance from file system, else from db.") .create("evalKernel"); Option exportBagOfWords = OptionBuilder.withDescription("exportBagOfWords. Must specify property file") .hasArg().create("exportBagOfWords"); Option exportType = OptionBuilder.withDescription("exportType. either libsvm or weka").hasArg() .create("exportType"); Option oLoadInstanceMap = OptionBuilder.withArgName("instanceMap.obj").hasArg() .withDescription(// w w w . j a v a 2s .co m "load instanceMap from file system instead of from db. Use after storing instance map.") .create("loadInstanceMap"); Option oEvalMod = OptionBuilder.withDescription("for parallelization, split the instances into mod slices") .hasArg().create("mod"); Option oEvalSlice = OptionBuilder.withDescription( "for parallelization, parameter that determines which slice we work on. If this is not specified, nMod threads will be started to evaluate all slices in parallel.") .hasArg().create("slice"); Option oBeanref = OptionBuilder.withArgName("classpath*:simSvcBeanRefContext.xml").hasArg() .withDescription("use specified beanRefContext.xml, default classpath*:simSvcBeanRefContext.xml") .create("beanref"); Option oAppctx = OptionBuilder.withArgName("kernelApplicationContext").hasArg() .withDescription("use specified applicationContext, default kernelApplicationContext") .create("appctx"); Option oBeans = OptionBuilder.withArgName("beans-corpus.xml").hasArg() .withDescription("use specified beans.xml, no default. This file is typically required.") .create("beans"); Option oHelp = new Option("help", "print this message"); Options options = new Options(); OptionGroup og = new OptionGroup(); og.addOption(oStoreInstanceMap); og.addOption(oEvaluateKernel); og.addOption(exportBagOfWords); options.addOptionGroup(og); // options.addOption(oStoreInstanceMap); options.addOption(oEvaluateKernel); // options.addOption(exportBagOfWords); options.addOption(exportType); options.addOption(oLoadInstanceMap); options.addOption(oEvalMod); options.addOption(oEvalSlice); options.addOption(oBeanref); options.addOption(oAppctx); options.addOption(oBeans); options.addOption(oHelp); return options; }
From source file:org.apache.geronimo.cli.BaseCLParser.java
protected void addOptionWithParam(String longOption, String shortOption, String argName, String desc) { OptionBuilder optionBuilder = OptionBuilder.hasArg().withArgName(argName); optionBuilder = optionBuilder.withLongOpt(longOption); optionBuilder = optionBuilder.withDescription(desc); Option option = optionBuilder.create(shortOption); options.addOption(option);//from w w w .j av a2s. co m }