List of usage examples for org.apache.commons.cli OptionBuilder hasArg
public static OptionBuilder hasArg()
From source file:org.apache.ambari.client.StackList.java
public void addOptions() { Option help = new Option("help", "Help"); Option tree = new Option("tree", "tree representation"); OptionBuilder.withArgName("name"); OptionBuilder.hasArg(); OptionBuilder.withDescription("Name of the stack"); Option name = OptionBuilder.create("name"); this.options = new Options(); options.addOption(name);//from w w w . j a v a 2 s .c om options.addOption(tree); options.addOption(help); }
From source file:org.apache.avalon.merlin.cli.Main.java
private static Options buildCommandLineOptions() { Options options = new Options(); Option help = new Option("help", REZ.getString("cli-help-description")); Option offline = new Option("offline", REZ.getString("cli-offline-description")); Option version = new Option("version", REZ.getString("cli-version-description")); Option execute = new Option("execute", REZ.getString("cli-execute-description")); Option debug = new Option("debug", REZ.getString("cli-debug-description")); Option noproxy = new Option("noproxy", REZ.getString("cli-noproxy-description")); Option audit = new Option("audit", REZ.getString("cli-audit-description")); Option info = new Option("info", REZ.getString("cli-info-description")); Option secure = new Option("secure", REZ.getString("cli-secure-description")); Option locale = OptionBuilder.hasArg().withArgName("code") .withDescription(REZ.getString("cli-language-description")).create("lang"); Option implementation = OptionBuilder.hasArg().withArgName("artifact") .withDescription(REZ.getString("cli-implementation-description")).create("impl"); Option home = OptionBuilder.hasArg().withArgName(REZ.getString("directory")) .withDescription(REZ.getString("cli-home-description")).create("home"); Option context = OptionBuilder.hasArg().withArgName(REZ.getString("directory")) .withDescription(REZ.getString("cli-context-description")).create("context"); Option system = OptionBuilder.hasArg().withArgName(REZ.getString("directory")) .withDescription(REZ.getString("cli-system-description")).create("system"); Option repository = OptionBuilder.hasArg().withArgName(REZ.getString("directory")) .withDescription(REZ.getString("cli-repository-description")).create("repository"); Option anchor = OptionBuilder.hasArg().withArgName(REZ.getString("directory")) .withDescription(REZ.getString("cli-anchor-description")).create("anchor"); Option config = OptionBuilder.hasArg().withArgName(REZ.getString("url")) .withDescription(REZ.getString("cli-config-description")).create("config"); Option kernel = OptionBuilder.hasArg().withArgName(REZ.getString("url")) .withDescription(REZ.getString("cli-kernel-description")).create("kernel"); Option install = OptionBuilder.hasArg().withArgName(REZ.getString("url")) .withDescription(REZ.getString("cli-install-description")).create("install"); options.addOption(help);//from w ww .j a va2s.co m options.addOption(locale); options.addOption(offline); options.addOption(execute); options.addOption(version); options.addOption(info); options.addOption(debug); options.addOption(audit); options.addOption(noproxy); options.addOption(secure); options.addOption(install); options.addOption(home); options.addOption(context); options.addOption(system); options.addOption(repository); options.addOption(anchor); options.addOption(config); options.addOption(kernel); options.addOption(implementation); return options; }
From source file:org.apache.avalon.repository.cli.Main.java
private static Options buildCommandLineOptions() { Options options = new Options(); Option help = new Option("help", REZ.getString("cli-help-description")); Option verify = new Option("verify", REZ.getString("cli-verify-description")); Option version = new Option("version", REZ.getString("cli-version-description")); Option locale = OptionBuilder.hasArg().withArgName("code") .withDescription(REZ.getString("cli-language-description")).create("lang"); Option info = new Option("info", REZ.getString("cli-info-description")); Option implementation = OptionBuilder.hasArg().withArgName("artifact") .withDescription(REZ.getString("cli-implementation-description")).create("impl"); Option home = OptionBuilder.hasArg().withArgName(REZ.getString("directory")) .withDescription(REZ.getString("cli-home-description")).create("home"); Option cache = OptionBuilder.hasArg().withArgName(REZ.getString("directory")) .withDescription(REZ.getString("cli-cache-description")).create("cache"); Option hosts = OptionBuilder.hasArg().withArgName(REZ.getString("urls")) .withDescription(REZ.getString("cli-hosts-description")).create("hosts"); Option install = OptionBuilder.hasArg().withArgName(REZ.getString("url")) .withDescription(REZ.getString("cli-install-description")).create("install"); options.addOption(help);/*from w w w . jav a 2 s . co m*/ options.addOption(locale); options.addOption(version); options.addOption(info); options.addOption(implementation); options.addOption(install); options.addOption(home); options.addOption(cache); options.addOption(hosts); options.addOption(verify); return options; }
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;/*from w w w. ja v a 2 s .co m*/ 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// w w w . ja v a 2 s . co m .withDescription("Disables the blockcache for this table. (Enabled by default)").create("b")); options.addOption(OptionBuilder .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.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));/*from w w w.ja v a 2s.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.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 ww w . j a va 2 s . c o m*/ }
From source file:org.apache.geronimo.cli.deployer.DistributeCommandArgsImpl.java
protected void addTargets() { OptionBuilder optionBuilder = OptionBuilder.hasArg().withArgName("targets"); optionBuilder = optionBuilder.withLongOpt(ARGUMENT_TARGETS); optionBuilder = optionBuilder//ww w .jav a 2 s. c om .withDescription("If no targets are provided, the module is distributed to all available " + "targets. Geronimo only provides one target (ever), so this is primarily " + "useful when using a different driver.\n"); Option option = optionBuilder.create(ARGUMENT_TARGETS_SHORTFORM); options.addOption(option); }
From source file:org.apache.geronimo.cli.deployer.InstallBundleCommandArgsImpl.java
protected void addStartLevel() { OptionBuilder optionBuilder = OptionBuilder.hasArg().withArgName("startLevel"); optionBuilder = optionBuilder.withLongOpt(ARGUMENT_START_LEVEL); optionBuilder = optionBuilder.withDescription( "If no start level are provided, will use the framework's initial bundle start level"); Option option = optionBuilder.create(ARGUMENT_START_LEVEL_SHORTFORM); options.addOption(option);//from www .ja v a 2 s. c o m }
From source file:org.apache.geronimo.cli.deployer.InstallBundleCommandArgsImpl.java
protected void addGroupId() { OptionBuilder optionBuilder = OptionBuilder.hasArg().withArgName("groupId"); optionBuilder = optionBuilder.withLongOpt(ARGUMENT_GROUP_ID); optionBuilder = optionBuilder/*w ww .jav a2 s .c o m*/ .withDescription("If gourpId is not provided, will use \"default\" as its group id."); Option option = optionBuilder.create(ARGUMENT_GROUP_ID_SHORTFORM); options.addOption(option); }