List of usage examples for org.apache.commons.cli Option setRequired
public void setRequired(boolean required)
From source file:com.twitter.hraven.etl.JobFileProcessor.java
/** * Parse command-line arguments.//from w w w . ja va 2 s . c o m * * @param args * command line arguments passed to program. * @return parsed command line. * @throws ParseException */ private static CommandLine parseArgs(String[] args) throws ParseException { Options options = new Options(); // Input Option o = new Option("c", "cluster", true, "cluster for which jobs are processed"); o.setArgName("cluster"); o.setRequired(true); options.addOption(o); // Whether to skip existing files or not. o = new Option("r", "reprocess", false, "Reprocess only those records that have been marked to be reprocessed. Otherwise process all rows indicated in the processing records, but successfully processed job files are skipped."); o.setRequired(false); options.addOption(o); // Whether to aggregate or not. // if re-process is on, need to consider turning aggregation off o = new Option("a", "aggregate", true, "Whether to aggreagate job details or not."); o.setArgName("aggreagte"); o.setRequired(false); options.addOption(o); // Whether to force re-aggregation or not. o = new Option("ra", "re-aggregate", true, "Whether to re-aggreagate job details or not."); o.setArgName("re-aggreagte"); o.setRequired(false); options.addOption(o); // Batch o = new Option("b", "batchSize", true, "The number of files to process in one batch. Default " + DEFAULT_BATCH_SIZE); o.setArgName("batch-size"); o.setRequired(false); options.addOption(o); o = new Option("t", "threads", true, "Number of parallel threads to use to run Hadoop jobs simultaniously. Default = 1"); o.setArgName("thread-count"); o.setRequired(false); options.addOption(o); o = new Option("p", "processFileSubstring", true, "use only those process records where the process file path contains the provided string. Useful when processing production jobs in parallel to historic loads."); o.setArgName("processFileSubstring"); o.setRequired(false); options.addOption(o); // Debugging options.addOption("d", "debug", false, "switch on DEBUG log level"); o = new Option("zf", "costFile", true, "The cost properties file location on HDFS"); o.setArgName("costfile_loc"); o.setRequired(true); options.addOption(o); // Machine type o = new Option("m", "machineType", true, "The type of machine this job ran on"); o.setArgName("machinetype"); o.setRequired(true); options.addOption(o); CommandLineParser parser = new PosixParser(); CommandLine commandLine = null; try { commandLine = parser.parse(options, args); } catch (Exception e) { System.err.println("ERROR: " + e.getMessage() + "\n"); HelpFormatter formatter = new HelpFormatter(); formatter.printHelp(NAME + " ", options, true); System.exit(-1); } // Set debug level right away if (commandLine.hasOption("d")) { Logger log = Logger.getLogger(JobFileProcessor.class); log.setLevel(Level.DEBUG); } return commandLine; }
From source file:fll.scheduler.TableOptimizer.java
private static Options buildOptions() { final Options options = new Options(); Option option = new Option(SCHED_FILE_OPTION, "schedfile", true, "<file> the schedule file "); option.setRequired(true); options.addOption(option);/*from w w w. j av a 2s . c om*/ return options; }
From source file:com.basistech.lucene.tools.LuceneQueryTool.java
private static Options createOptions() { Options options = new Options(); Option option; option = new Option("i", "index", true, "index (required, multiple -i searches multiple indexes)"); option.setRequired(true); options.addOption(option);/* ww w . j ava 2 s. co m*/ option = new Option("q", "query", true, "(query | %all | %enumerate-fields " + "| %count-fields " + "| %enumerate-terms field " + "| %script scriptFile " + "| %ids id [id ...] | %id-file file) (required, scriptFile may contain -q and -o)"); option.setRequired(true); option.setArgs(Option.UNLIMITED_VALUES); options.addOption(option); option = new Option(null, "regex", true, "filter query by regex, syntax is field:/regex/"); option.setArgs(1); options.addOption(option); option = new Option(null, "fields", true, "fields to include in output (defaults to all)"); option.setArgs(Option.UNLIMITED_VALUES); options.addOption(option); option = new Option(null, "sort-fields", false, "sort fields within document"); options.addOption(option); option = new Option(null, "query-limit", true, "max number of query hits to process"); option.setArgs(1); options.addOption(option); option = new Option(null, "output-limit", true, "max number of docs to output"); option.setArgs(1); options.addOption(option); option = new Option(null, "analyzer", true, "for query, (KeywordAnalyzer | StandardAnalyzer) (defaults to KeywordAnalyzer)"); option.setArgs(1); options.addOption(option); option = new Option(null, "query-field", true, "default field for query"); option.setArgs(1); options.addOption(option); option = new Option(null, "show-id", false, "show Lucene document id in results"); options.addOption(option); option = new Option(null, "show-score", false, "show score in results"); options.addOption(option); option = new Option(null, "show-hits", false, "show total hit count"); options.addOption(option); option = new Option(null, "suppress-names", false, "suppress printing of field names"); options.addOption(option); option = new Option(null, "tabular", false, "print tabular output " + "(requires --fields with no multivalued fields)"); options.addOption(option); option = new Option("o", "output", true, "output file (defaults to standard output)"); option.setArgs(1); options.addOption(option); return options; }
From source file:com.linkedin.helix.tools.ClusterStateVerifier.java
@SuppressWarnings("static-access") private static Options constructCommandLineOptions() { Option helpOption = OptionBuilder.withLongOpt(help).withDescription("Prints command-line options info") .create();// www .j a v a 2 s . com Option zkServerOption = OptionBuilder.withLongOpt(zkServerAddress) .withDescription("Provide zookeeper address").create(); zkServerOption.setArgs(1); zkServerOption.setRequired(true); zkServerOption.setArgName("ZookeeperServerAddress(Required)"); Option clusterOption = OptionBuilder.withLongOpt(cluster).withDescription("Provide cluster name").create(); clusterOption.setArgs(1); clusterOption.setRequired(true); clusterOption.setArgName("Cluster name (Required)"); Option timeoutOption = OptionBuilder.withLongOpt(timeout).withDescription("Timeout value for verification") .create(); timeoutOption.setArgs(1); timeoutOption.setArgName("Timeout value (Optional), default=30s"); Option sleepIntervalOption = OptionBuilder.withLongOpt(period) .withDescription("Polling period for verification").create(); sleepIntervalOption.setArgs(1); sleepIntervalOption.setArgName("Polling period value (Optional), default=1s"); Options options = new Options(); options.addOption(helpOption); options.addOption(zkServerOption); options.addOption(clusterOption); options.addOption(timeoutOption); options.addOption(sleepIntervalOption); return options; }
From source file:kieker.tools.bridge.cli.CLIServerMain.java
/** * Compile the options for the CLI server. * * @return The composed options for the CLI server *///from www.j a v a 2 s .com private static Options declareOptions() { options = new Options(); Option option; // Type selection option = new Option(CMD_TYPE, CMD_TYPE_LONG, true, "select the service type: tcp-client, tcp-server, tcp-single-server, jms-client, jms-embedded, http-rest"); option.setArgName("type"); option.setRequired(true); options.addOption(option); // TCP client option = new Option(CMD_HOST, CMD_HOST_LONG, true, "connect to server named <hostname>"); option.setArgName("hostname"); options.addOption(option); // TCP server option = new Option(CMD_PORT, CMD_PORT_LONG, true, "listen at port (tcp-server, jms-embedded, or http-rest) or connect to port (tcp-client)"); option.setArgName("number"); option.setType(Number.class); options.addOption(option); // JMS client option = new Option(CMD_USER, CMD_USER_LONG, true, "user name for a JMS service"); option.setArgName("username"); options.addOption(option); option = new Option(CMD_PASSWORD, CMD_PASSWORD_LONG, true, "password for a JMS service"); option.setArgName("password"); options.addOption(option); option = new Option(CMD_URL, CMD_URL_LONG, true, "URL for JMS server or HTTP servlet"); option.setArgName("jms-url"); option.setType(URL.class); options.addOption(option); // HTTP client option = new Option(CMD_CONTEXT, CMD_CONTEXT_LONG, true, "context for the HTTP servlet"); option.setArgName("context"); options.addOption(option); // kieker configuration file option = new Option(CMD_KIEKER_CONFIGURATION, CMD_KIEKER_CONFIGURATION_LONG, true, "kieker configuration file"); option.setArgName("configuration"); options.addOption(option); // mapping file for TCP and JMS option = new Option(CMD_MAP_FILE, CMD_MAP_FILE_LONG, true, "Class name to id (integer or string) mapping"); option.setArgName("map-file"); option.setType(File.class); option.setRequired(true); options.addOption(option); // libraries option = new Option(CMD_LIBRARIES, CMD_LIBRARIES_LONG, true, "List of library paths separated by " + File.pathSeparatorChar); option.setArgName("paths"); option.setType(File.class); option.setRequired(true); option.setValueSeparator(File.pathSeparatorChar); options.addOption(option); // verbose option = new Option(CMD_VERBOSE, CMD_VERBOSE_LONG, true, "output processing information"); option.setRequired(false); option.setOptionalArg(true); options.addOption(option); // statistics option = new Option(CMD_STATS, CMD_STATS_LONG, false, "output performance statistics"); option.setRequired(false); options.addOption(option); // daemon mode option = new Option(CMD_DAEMON, CMD_DAEMON_LONG, false, "detach from console; TCP server allows multiple connections"); option.setRequired(false); options.addOption(option); return options; }
From source file:net.lldp.checksims.ChecksimsCommandLine.java
/** * @param anyRequired Whether any arguments are required * @return CLI options used in Checksims *///from w w w. j a v a 2s.co m static Options getOpts(boolean anyRequired) { Options opts = new Options(); Option alg = Option.builder("a").longOpt("algorithm").hasArg().argName("name") .desc("algorithm to compare with").build(); Option token = Option.builder("t").longOpt("token").hasArg().argName("type") .desc("tokenization to use for submissions").build(); Option out = Option.builder("o").longOpt("output").hasArgs().argName("name1[,name2,...]") .valueSeparator(',').desc("output format(s) to use, comma-separated if multiple given").build(); Option ignoreInvalid = Option.builder().longOpt("ignoreInvalid") .desc("Do not show the result of submissions that do not parse correctly").build(); Option file = Option.builder("f").longOpt("file").hasArg().argName("filename") .desc("print output to given file").build(); Option preprocess = Option.builder("p").longOpt("preprocess").hasArgs().argName("name1[,name2,...]") .valueSeparator(',').desc("preprocessor(s) to apply, comma-separated if multiple given").build(); Option jobs = Option.builder("j").longOpt("jobs").hasArg().argName("num").desc("number of threads to use") .build(); Option glob = Option.builder("g").longOpt("glob").hasArg().argName("matchpattern") .desc("match pattern to determine files included in submissions").build(); OptionGroup verbosity = new OptionGroup(); Option verbose = new Option("v", "verbose", false, "specify verbose output. conflicts with -vv"); Option doubleVerbose = new Option("vv", "veryverbose", false, "specify very verbose output. conflicts with -v"); verbosity.addOption(verbose); verbosity.addOption(doubleVerbose); Option help = new Option("h", "help", false, "show usage information"); Option empty = new Option("e", "empty", false, "retain empty submissions"); Option common = Option.builder("c").longOpt("common").hasArg().argName("path") .desc("directory containing common code which will be removed from all submissions").build(); Option recursive = new Option("r", "recursive", false, "recursively traverse subdirectories to generate submissions"); Option version = new Option("version", false, "print version of Checksims"); Option archiveDir = Option.builder("archive").longOpt("archivedir") .desc("archive submissions - compared to main submissions but not each other").argName("path") .hasArgs().valueSeparator('*').build(); Option submissionDir = Option.builder("s").longOpt("submissiondir") .desc("directory or directories containing submissions to compare - mandatory!").argName("path") .hasArgs().valueSeparator('*').build(); if (anyRequired) { submissionDir.setRequired(true); } opts.addOption(alg); opts.addOption(token); opts.addOption(out); opts.addOption(file); opts.addOption(preprocess); opts.addOption(jobs); opts.addOption(glob); opts.addOptionGroup(verbosity); opts.addOption(help); opts.addOption(empty); opts.addOption(common); opts.addOption(recursive); opts.addOption(version); opts.addOption(archiveDir); opts.addOption(submissionDir); opts.addOption(ignoreInvalid); return opts; }
From source file:com.zimbra.kabuki.tools.img.ImageMerger.java
private static void addOption(String shortParam, String longParam, boolean takesArg, String description, boolean required) { Option option = new Option(shortParam, longParam, takesArg, description); option.setRequired(required); OPTIONS.addOption(option);/*from ww w .j a v a 2s.com*/ }
From source file:com.alibaba.rocketmq.tools.command.message.DecodeMessageIdCommond.java
@Override public Options buildCommandlineOptions(Options options) { Option opt = new Option("i", "messageId", true, "unique message ID"); opt.setRequired(false); options.addOption(opt);//from w ww . j a v a 2s . c o m return options; }
From source file:com.alibaba.rocketmq.tools.command.topic.TopicClusterSubCommand.java
@Override public Options buildCommandlineOptions(Options options) { Option opt = new Option("t", "topic", true, "topic name"); opt.setRequired(true); options.addOption(opt);//from ww w.j a v a 2 s . c om return options; }
From source file:com.alibaba.rocketmq.tools.command.topic.TopicRouteSubCommand.java
@Override public Options buildCommandlineOptions(Options options) { Option opt = new Option("t", "topic", true, "topic name"); opt.setRequired(true); options.addOption(opt);// www . jav a 2 s . c o m return options; }