List of usage examples for org.apache.commons.cli OptionBuilder hasArgs
public static OptionBuilder hasArgs()
From source file:norbert.mynemo.ui.ImportCommandParser.java
private static Options getOptions() { OptionBuilder.isRequired();//from w w w.ja v a 2 s .c o m OptionBuilder.hasArg(); OptionBuilder.withArgName(OUT_ARG_NAME); OptionBuilder.withDescription(OUT_DESCRIPTION); OptionBuilder.withLongOpt(OUT_LONG_OPTION); Option out = OptionBuilder.create(OUT_CHAR_OPTION); OptionBuilder.isRequired(); OptionBuilder.hasArgs(); OptionBuilder.withArgName(RATINGS_ARG_NAME); OptionBuilder.withLongOpt(RATINGS_LONG_OPTION); OptionBuilder.withDescription(RATINGS_DESCRIPTION); Option ratings = OptionBuilder.create(RATINGS_CHAR_OPTION); OptionBuilder.hasArg(); OptionBuilder.withArgName(MOVIES_ARG_NAME); OptionBuilder.withLongOpt(MOVIES_LONG_OPTION); OptionBuilder.withDescription(MOVIES_DESCRIPTION); Option movies = OptionBuilder.create(MOVIES_CHAR_OPTION); OptionBuilder.hasArg(); OptionBuilder.withArgName(USER_ARG_NAME); OptionBuilder.withLongOpt(USER_LONG_OPTION); OptionBuilder.withDescription(USER_DESCRIPTION); Option user = OptionBuilder.create(USER_CHAR_OPTION); OptionBuilder.hasArg(); OptionBuilder.withArgName(MAX_USERS_ARG_NAME); OptionBuilder.withLongOpt(MAX_USERS_LONG_OPTION); OptionBuilder.withDescription(MAX_USERS_DESCRIPTION); Option maxUsers = OptionBuilder.create(); OptionBuilder.hasArg(); OptionBuilder.withArgName(MIN_RATINGS_BY_MOVIE_ARG_NAME); OptionBuilder.withLongOpt(MIN_RATINGS_BY_MOVIE_LONG_OPTION); OptionBuilder.withDescription(MIN_RATINGS_BY_MOVIE_DESCRIPTION); Option minRatingsByMovie = OptionBuilder.create(); OptionBuilder.hasArg(); OptionBuilder.withArgName(MIN_COMMON_RATINGS_ARG_NAME); OptionBuilder.withLongOpt(MIN_COMMON_RATINGS_LONG_OPTION); OptionBuilder.withDescription(MIN_COMMON_RATINGS_DESCRIPTION); Option minCommonRatings = OptionBuilder.create(); OptionBuilder.hasArg(); OptionBuilder.withArgName(SIMILARITY_ARG_NAME); OptionBuilder.withLongOpt(SIMILARITY_LONG_OPTION); OptionBuilder.withDescription(SIMILARITY_DESCRIPTION); Option similarity = OptionBuilder.create(SIMILARITY_CHAR_OPTION); return new Options().addOption(out).addOption(ratings).addOption(movies).addOption(user).addOption(maxUsers) .addOption(minRatingsByMovie).addOption(minCommonRatings).addOption(similarity); }
From source file:norbert.mynemo.ui.ScrapeCommandParser.java
private static Options getOptions() { // out movies OptionBuilder.isRequired();//from w w w. j a va 2s . com OptionBuilder.hasArg(); OptionBuilder.withArgName(OUT_MOVIES_ARG_NAME); OptionBuilder.withLongOpt(OUT_MOVIES_LONG_OPTION); OptionBuilder.withDescription(OUT_MOVIES_DESCRIPTION); Option outMovies = OptionBuilder.create(OUT_MOVIES_CHAR_OPTION); // out ratings OptionBuilder.isRequired(); OptionBuilder.hasArg(); OptionBuilder.withArgName(OUT_RATINGS_ARG_NAME); OptionBuilder.withLongOpt(OUT_RATINGS_LONG_OPTION); OptionBuilder.withDescription(OUT_RATINGS_DESCRIPTION); Option outRatings = OptionBuilder.create(OUT_RATINGS_CHAR_OPTION); // input files OptionBuilder.isRequired(); OptionBuilder.hasArgs(); OptionBuilder.withArgName(IN_ARG_NAME); OptionBuilder.withLongOpt(IN_LONG_OPTION); OptionBuilder.withDescription(IN_DESCRIPTION); Option in = OptionBuilder.create(IN_CHAR_OPTION); // user agent file OptionBuilder.isRequired(); OptionBuilder.hasArg(); OptionBuilder.withArgName(USERAGENTS_ARG_NAME); OptionBuilder.withLongOpt(USERAGENTS_LONG_OPTION); OptionBuilder.withDescription(USERAGENTS_DESCRIPTION); Option userAgents = OptionBuilder.create(USERAGENTS_CHAR_OPTION); // movie blacklist file OptionBuilder.isRequired(); OptionBuilder.hasArg(); OptionBuilder.withArgName(MOVIE_BLACKLIST_ARG_NAME); OptionBuilder.withLongOpt(MOVIE_BLACKLIST_LONG_OPTION); OptionBuilder.withDescription(MOVIE_BLACKLIST_DESCRIPTION); Option movieBlacklist = OptionBuilder.create(); // user blacklist file OptionBuilder.isRequired(); OptionBuilder.hasArg(); OptionBuilder.withArgName(USER_BLACKLIST_ARG_NAME); OptionBuilder.withLongOpt(USER_BLACKLIST_LONG_OPTION); OptionBuilder.withDescription(USER_BLACKLIST_DESCRIPTION); Option userBlacklist = OptionBuilder.create(); return new Options().addOption(outMovies).addOption(outRatings).addOption(in).addOption(userAgents) .addOption(movieBlacklist).addOption(userBlacklist); }
From source file:norbert.mynemo.ui.SelectCommandParser.java
private static Options getOptions() { OptionBuilder.isRequired();//from w w w . j ava 2s. c o m OptionBuilder.hasArg(); OptionBuilder.withArgName(DATAMODEL_ARG_NAME); OptionBuilder.withDescription(DATAMODEL_DESCRIPTION); OptionBuilder.withLongOpt(DATAMODEL_LONG_OPTION); Option dataModel = OptionBuilder.create(DATAMODEL_CHAR_OPTION); OptionBuilder.isRequired(); OptionBuilder.hasArg(); OptionBuilder.withArgName(USER_ARG_NAME); OptionBuilder.withLongOpt(USER_LONG_OPTION); OptionBuilder.withDescription(USER_DESCRIPTION); Option user = OptionBuilder.create(USER_CHAR_OPTION); OptionBuilder.hasArgs(); OptionBuilder.withArgName(ALGORITHMS_ARG_NAME); OptionBuilder.withLongOpt(ALGORITHMS_LONG_OPTION); OptionBuilder.withDescription(ALGORITHMS_DESCRIPTION); Option algorithms = OptionBuilder.create(ALGORITHMS_CHAR_OPTION); OptionBuilder.hasArg(); OptionBuilder.withArgName(METRIC_ARG_NAME); OptionBuilder.withLongOpt(METRIC_LONG_OPTION); OptionBuilder.withDescription(METRIC_DESCRIPTION); Option metric = OptionBuilder.create(METRIC_CHAR_OPTION); OptionBuilder.hasArg(); OptionBuilder.withArgName(SPEED_ARG_NAME); OptionBuilder.withLongOpt(SPEED_LONG_OPTION); OptionBuilder.withDescription(SPEED_DESCRIPTION); Option speed = OptionBuilder.create(SPEED_CHAR_OPTION); OptionBuilder.hasArg(); OptionBuilder.withArgName(COVERAGE_ARG_NAME); OptionBuilder.withLongOpt(COVERAGE_LONG_OPTION); OptionBuilder.withDescription(COVERAGE_DESCRIPTION); Option coverage = OptionBuilder.create(COVERAGE_CHAR_OPTION); return new Options().addOption(dataModel).addOption(user).addOption(algorithms).addOption(metric) .addOption(speed).addOption(coverage); }
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 ww . ja va 2 s . c o 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.daemon.DaemonCLParser.java
protected void addOverride() { OptionBuilder optionBuilder = OptionBuilder.hasArgs().withArgName("moduleId ..."); optionBuilder = optionBuilder.withLongOpt(ARGUMENT_MODULE_OVERRIDE); optionBuilder = optionBuilder.withDescription("USE WITH CAUTION! Overrides the modules in " + "var/config/config.xml such that only the modules listed on " + "the command line will be started. Note that many J2EE " + "features depend on certain modules being started, so you " + "should be very careful what you omit. Any arguments after " + "this are assumed to be module names."); Option option = optionBuilder.create(ARGUMENT_MODULE_OVERRIDE_SHORTFORM); options.addOption(option);//w ww. j a v a 2 s . co m }
From source file:org.apache.hadoop.hdfs.tools.offlineEditsViewer.OfflineEditsViewer.java
/** * Build command-line options and descriptions * * @return command line options/* w ww . j a v a 2 s .c o m*/ */ public static Options buildOptions() { Options options = new Options(); // Build in/output file arguments, which are required, but there is no // addOption method that can specify this OptionBuilder.isRequired(); OptionBuilder.hasArgs(); OptionBuilder.withLongOpt("outputFilename"); options.addOption(OptionBuilder.create("o")); OptionBuilder.isRequired(); OptionBuilder.hasArgs(); OptionBuilder.withLongOpt("inputFilename"); options.addOption(OptionBuilder.create("i")); options.addOption("p", "processor", true, ""); options.addOption("v", "verbose", false, ""); options.addOption("f", "fix-txids", false, ""); options.addOption("r", "recover", false, ""); options.addOption("h", "help", false, ""); return options; }
From source file:org.apache.hadoop.hdfs.tools.offlineImageViewer.OfflineImageDecompressor.java
/** * Build command-line options and descriptions *///from w w w . j a v a2s . c o m public static Options buildOptions() { Options options = new Options(); // Build in/output file arguments, which are required, but there is no // addOption method that can specify this OptionBuilder.isRequired(); OptionBuilder.hasArgs(); OptionBuilder.withLongOpt("outputFile"); options.addOption(OptionBuilder.create("o")); OptionBuilder.isRequired(); OptionBuilder.hasArgs(); OptionBuilder.withLongOpt("inputFile"); options.addOption(OptionBuilder.create("i")); options.addOption("h", "help", false, ""); return options; }
From source file:org.apache.hadoop.hdfs.tools.offlineImageViewer.OfflineImageViewer.java
/** * Build command-line options and descriptions */// w ww. j a v a 2 s. c om public static Options buildOptions() { Options options = new Options(); // Build in/output file arguments, which are required, but there is no // addOption method that can specify this OptionBuilder.isRequired(); OptionBuilder.hasArgs(); OptionBuilder.withLongOpt("outputFile"); options.addOption(OptionBuilder.create("o")); OptionBuilder.isRequired(); OptionBuilder.hasArgs(); OptionBuilder.withLongOpt("inputFile"); options.addOption(OptionBuilder.create("i")); options.addOption("p", "processor", true, ""); options.addOption("h", "help", false, ""); options.addOption("skipBlocks", false, ""); options.addOption("printToScreen", false, ""); options.addOption("delimiter", true, ""); return options; }
From source file:org.apache.hadoop.hdfs.tools.offlineImageViewer.OfflineImageViewerPB.java
/** * Build command-line options and descriptions *//* w ww . j a v a 2s . c om*/ private static Options buildOptions() { Options options = new Options(); // Build in/output file arguments, which are required, but there is no // addOption method that can specify this OptionBuilder.isRequired(); OptionBuilder.hasArgs(); OptionBuilder.withLongOpt("inputFile"); options.addOption(OptionBuilder.create("i")); options.addOption("o", "outputFile", true, ""); options.addOption("p", "processor", true, ""); options.addOption("h", "help", false, ""); options.addOption("maxSize", true, ""); options.addOption("step", true, ""); options.addOption("addr", true, ""); options.addOption("delimiter", true, ""); options.addOption("t", "temp", true, ""); return options; }
From source file:org.apache.hadoop.mapreduce.MiniHadoopClusterManager.java
/** * Creates configuration options object. *//*from ww w .java2 s . c om*/ @SuppressWarnings("static-access") private Options makeOptions() { Options options = new Options(); options.addOption("nodfs", false, "Don't start a mini DFS cluster") .addOption("nomr", false, "Don't start a mini MR cluster") .addOption("nodemanagers", true, "How many nodemanagers to start (default 1)") .addOption("datanodes", true, "How many datanodes to start (default 1)") .addOption("format", false, "Format the DFS (default false)") .addOption("nnport", true, "NameNode port (default 0--we choose)") .addOption("namenode", true, "URL of the namenode (default " + "is either the DFS cluster or a temporary dir)") .addOption("rmport", true, "ResourceManager port (default 0--we choose)") .addOption("jhsport", true, "JobHistoryServer port (default 0--we choose)") .addOption(OptionBuilder.hasArgs().withArgName("property=value") .withDescription("Options to pass into configuration object").create("D")) .addOption(OptionBuilder.hasArg().withArgName("path") .withDescription("Save configuration to this XML file.").create("writeConfig")) .addOption(OptionBuilder.hasArg().withArgName("path") .withDescription("Write basic information to this JSON file.").create("writeDetails")) .addOption(OptionBuilder.withDescription("Prints option help.").create("help")); return options; }