List of usage examples for org.apache.commons.cli OptionBuilder withLongOpt
public static OptionBuilder withLongOpt(String newLongopt)
From source file:com.ibm.bi.dml.debug.DMLDebuggerInterface.java
/** * Set DML debugger CLI functionality menu *//*w ww . ja v a 2 s . co m*/ @SuppressWarnings("static-access") public void setOptions() { //add help option options.addOption("h", "help", false, "list debugger functions"); //add run option options.addOption("r", "run", false, "start your DML script"); //add quit option options.addOption("q", "quit", false, "exit debug mode"); //add resume option options.addOption("c", "continue", false, "continue running your DML script"); //add step over //options.addOption("n", "next", false, "next line, stepping over function calls"); //add single-stepping options.addOption("s", "step", false, "next line, stepping into function calls"); //add single-stepping options.addOption("si", "stepi", false, "next runtime instruction rather than DML source lines (for advanced users)"); // No step return for now //add step return // Option stepReturn = OptionBuilder.withArgName( "function-name" ) // .hasOptionalArg() // .withDescription( "execute instructions associated with current function as single step") // .create( "step_return" ); // options.addOption(stepReturn); //add set breakpoint option Option setBreakpoint = OptionBuilder.withLongOpt("break").withArgName("line-number").hasArg() .withDescription("set breakpoint at given line number").create("b"); options.addOption(setBreakpoint); // The key assumption here is that user doesnot keep toggling breakpoints too often //add delete breakpoint option Option disableBreakpoint = OptionBuilder.withLongOpt("delete").withArgName("line-number").hasArg() .withDescription("delete breakpoint at given line number").create("d"); options.addOption(disableBreakpoint); //add list breakpoints option Option infoOption = OptionBuilder.withLongOpt("info").withArgName("[break | frame]").hasOptionalArgs(1) .withDescription("show all breakpoints or frames (info <break | frame>)").create("i"); options.addOption(infoOption); //add display DML script option Option displayScript = OptionBuilder.withLongOpt("list") .withArgName("[next numlines] | [prev numlines] | [all]").hasOptionalArgs(2).withValueSeparator(' ') .withDescription("display DML script source lines. Default: numlines = 10").create("l"); options.addOption(displayScript); //add display DML script interspersed with runtime instructions option Option displayInst = OptionBuilder.withLongOpt("listi") .withArgName("[next numlines] | [prev numlines] | [all]").hasOptionalArgs(2).withValueSeparator(' ') .withDescription( "display corresponding instructions for DML script source lines. Default: numlines = 10 (for advanced users)") .create("li"); options.addOption(displayInst); //add set value of DML scalar variable option Option setVar = OptionBuilder.withArgName("varName value").hasArgs(2).withValueSeparator(' ') .withDescription( "set value of a scalar or specified cell of a matrix variable. (Eg: \'set alpha 0.1\' or \'set A[1,2] 20\')") .create("set"); options.addOption(setVar); //add display DML matrix (or vector) variable option Option displayMatrix = OptionBuilder.withLongOpt("print").withArgName("varName").hasArg().withDescription( "display contents of a scalar or matrix variable or rows/columns/cell of matrix. (Eg: \'p alpha\' or \'p A\' or \'p A[1,]\')") .create("p"); options.addOption(displayMatrix); Option displayTypeMatrix = OptionBuilder //.withLongOpt( "whatis" ) .withArgName("varName").hasArg() .withDescription( "display the type (and metadata) of a variable. (Eg: \'whatis alpha\' or \'whatis A\')") .create("whatis"); options.addOption(displayTypeMatrix); }
From source file:net.sf.texprinter.utils.CommandLineHelper.java
/** * Default constructor./* ww w . j a v a 2 s . co m*/ */ public CommandLineHelper() { // argument for question id Option questionIdOption = OptionBuilder.withLongOpt("question-id").withDescription("the TeX.SX question ID") .hasArg().withArgName("ID").create(); // argument for output format Option outputFormatOption = OptionBuilder.withLongOpt("output") .withDescription("the output format ('pdf' or 'tex')").hasArg().withArgName("EXT").create(); // argument for version Option versionOption = OptionBuilder.withLongOpt("version").withDescription("print the application version") .create(); // argument for help Option helpOption = OptionBuilder.withLongOpt("help").withDescription("print the help message").create(); // create a new list of options commandLineOptions = new Options(); // add the question id commandLineOptions.addOption(questionIdOption); // add the output format commandLineOptions.addOption(outputFormatOption); // add the version commandLineOptions.addOption(versionOption); // add the help commandLineOptions.addOption(helpOption); }
From source file:be.svlandeg.diffany.console.DiffanyOptions.java
/** * Define the options specifying necessary arguments for the Diffany algorithms *///w ww . ja v a 2 s. c om 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:com.linkedin.databus.bootstrap.utils.BootstrapDBCleanerMain.java
@SuppressWarnings("static-access") public static void parseArgs(String[] args) throws IOException { CommandLineParser cliParser = new GnuParser(); Option helpOption = OptionBuilder.withLongOpt(HELP_OPT_LONG_NAME).withDescription("Help screen") .create(HELP_OPT_CHAR);// w ww . ja v a 2 s . co m Option dbOption = OptionBuilder.withLongOpt(BOOTSTRAP_DB_PROPS_OPT_LONG_NAME) .withDescription("Bootstrap Cleaner and DB properties to use").hasArg().withArgName("property_file") .create(BOOTSTRAP_DB_PROP_OPT_CHAR); Option cmdLinePropsOption1 = OptionBuilder.withLongOpt(CLEANER_CMD_LINE_PROPS_OPT_LONG_NAME) .withDescription("Cmd line override of cleaner config properties. Semicolon separated.").hasArg() .withArgName("Semicolon_separated_properties").create(CLEANER_CMD_LINE_PROPS_OPT_CHAR); Option log4jPropsOption = OptionBuilder.withLongOpt(LOG4J_PROPS_OPT_LONG_NAME) .withDescription("Log4j properties to use").hasArg().withArgName("property_file") .create(LOG4J_PROPS_OPT_CHAR); Option sourcesOption = OptionBuilder.withLongOpt(BOOTSTRAP_SOURCES_OPT_LONG_NAME) .withDescription( "Comma seperated list of sourceNames. If not provided, no source will be cleaned up") .hasArg().withArgName("comma-seperated sources").create(BOOTSTRAP_SOURCES_PROP_OPT_CHAR); Options options = new Options(); options.addOption(helpOption); options.addOption(dbOption); options.addOption(cmdLinePropsOption1); options.addOption(log4jPropsOption); options.addOption(sourcesOption); CommandLine cmd = null; try { cmd = cliParser.parse(options, args); } catch (ParseException pe) { LOG.error("Bootstrap Physical Config: failed to parse command-line options.", pe); throw new RuntimeException("Bootstrap Physical Config: failed to parse command-line options.", pe); } if (cmd.hasOption(LOG4J_PROPS_OPT_CHAR)) { String log4jPropFile = cmd.getOptionValue(LOG4J_PROPS_OPT_CHAR); PropertyConfigurator.configure(log4jPropFile); LOG.info("Using custom logging settings from file " + log4jPropFile); } else { PatternLayout defaultLayout = new PatternLayout("%d{ISO8601} +%r [%t] (%p) {%c} %m%n"); ConsoleAppender defaultAppender = new ConsoleAppender(defaultLayout); Logger.getRootLogger().removeAllAppenders(); Logger.getRootLogger().addAppender(defaultAppender); LOG.info("Using default logging settings"); } if (cmd.hasOption(HELP_OPT_CHAR)) { printCliHelp(options); System.exit(0); } if (cmd.hasOption(BOOTSTRAP_SOURCES_PROP_OPT_CHAR)) { _sSources = new ArrayList<String>(); String srcListStr = cmd.getOptionValue(BOOTSTRAP_SOURCES_PROP_OPT_CHAR); LOG.info("Going to run cleaner for only these sources : " + srcListStr); String[] srcList = srcListStr.split(","); for (String s : srcList) _sSources.add(s); } if (!cmd.hasOption(BOOTSTRAP_DB_PROP_OPT_CHAR)) throw new RuntimeException("Bootstrap config is not provided"); String propFile = cmd.getOptionValue(BOOTSTRAP_DB_PROP_OPT_CHAR); LOG.info("Loading bootstrap DB config from properties file " + propFile); _sBootstrapConfigProps = new Properties(); FileInputStream f = new FileInputStream(propFile); try { _sBootstrapConfigProps.load(f); } finally { f.close(); } if (cmd.hasOption(CLEANER_CMD_LINE_PROPS_OPT_CHAR)) { String cmdLinePropString = cmd.getOptionValue(CLEANER_CMD_LINE_PROPS_OPT_CHAR); updatePropsFromCmdLine(_sBootstrapConfigProps, cmdLinePropString); } }
From source file:net.orpiske.ssps.sdm.actions.Installer.java
@Override protected void processCommand(String[] args) { CommandLineParser parser = new PosixParser(); options = new Options(); options.addOption("h", "help", false, "prints the help"); options.addOption("g", "groupid", true, "package group id"); options.addOption("p", "package", true, "package name"); options.addOption("r", "repository", true, "the name of the repository to use"); options.addOption(null, "cleanup", false, "cleanup the work directory after finished"); options.addOption(null, "reinstall", false, "reinstall already installed packages"); options.addOption(null, "view", false, "only view the packages to be installed"); Option phasesOptions = OptionBuilder.withLongOpt("phases").create(); phasesOptions.setArgs(6);/*from ww w .ja v a 2 s .co m*/ phasesOptions.setRequired(false); phasesOptions.setDescription("the install phase(s) to run (implies --nodeps)"); options.addOption(phasesOptions); options.addOption(null, "nodeps", false, "does not install dependencies"); options.addOption("v", "version", true, "version"); try { cmdLine = parser.parse(options, args); } catch (ParseException e) { help(options, -1); } isHelp = cmdLine.hasOption("help"); reinstall = cmdLine.hasOption("reinstall"); cleanup = cmdLine.hasOption("cleanup"); view = cmdLine.hasOption("view"); packageName = cmdLine.getOptionValue('p'); if (packageName == null) { help(options, -1); } groupId = cmdLine.getOptionValue('g'); version = cmdLine.getOptionValue('v'); phases = cmdLine.getOptionValues("phases"); if (phases != null && phases.length > 0) { nodeps = true; } else { nodeps = cmdLine.hasOption("nodeps"); } repository = cmdLine.getOptionValue('r'); }
From source file:de.tudarmstadt.lt.lm.app.GenerateNgramIndex.java
@SuppressWarnings("static-access") public GenerateNgramIndex(String[] args) { Options opts = new Options(); opts.addOption(OptionBuilder.withLongOpt("help").withDescription("Display help message.").create("?")); opts.addOption(OptionBuilder.withLongOpt("mincount").withArgName("int").hasArg().withDescription( "specify the number of times an ngram must occur to be considered in further calculations. Ngrams with counts below mincount are filtered. (default: 1).") .create("m")); opts.addOption(OptionBuilder.withLongOpt("overwrite").hasOptionalArg().withArgName("{true|false}") .withDescription("Overwrite existing index (default: false).").create("w")); // options parsed and passed to Ngrams app opts.addOption(OptionBuilder.withLongOpt("ptype").withArgName("class").hasArg().withDescription( "specify the instance of the language model provider that you want to use: {LtSegProvider, BreakIteratorStringProvider, UimaStringProvider, PreTokenizedStringProvider} (default: LtSegProvider)") .create("p")); opts.addOption(OptionBuilder.withLongOpt("cardinality").withArgName("ngram-order").hasArg().withDescription( "Specify the cardinality of the ngrams (min. 1). Specify a range using 'from-to'. (Examples: 5 = extract 5grams; 1-5 = extract 1grams, 2grams, ..., 5grams; default: 1-5).") .create("n")); opts.addOption(OptionBuilder.withLongOpt("file").withArgName("filename").hasArg().withDescription( "Specify the file or directory that contains '.txt' file to read from. Specify '-' to read from stdin. (Note: when no output directory is provided this parameter must refer to a directory!)") .isRequired().create("f")); opts.addOption(OptionBuilder.withLongOpt("dest").withArgName("directory").hasArg().withDescription( "Specify the index directory for the related language model files. (default: <srcdir>/.lmindex)") .create("d")); opts.addOption(OptionBuilder.withLongOpt("accross_sentences").hasOptionalArg().withArgName("{true|false}") .withDescription("Generate Ngrams across sentence boundaries.").create("a")); try {/*w w w. j a v a 2 s .c om*/ CommandLine cmd = new ExtendedGnuParser(true).parse(opts, args); if (cmd.hasOption("help")) CliUtils.print_usage_quit(System.err, Ngrams.class.getSimpleName(), opts, USAGE_HEADER, null, 0); _provider_type_ = cmd.getOptionValue("ptype", LtSegProvider.class.getSimpleName()); _file_ = cmd.getOptionValue("file", "-"); _out_ = cmd.getOptionValue("dest"); if (_out_ != null) _index_dir = new File(_out_); else { if ("-".equals(_file_)) throw new IllegalArgumentException( "Output directory must be provided when generating ngrams from stdin. Please provide a destination directory or generate ngrams from directory."); File f_or_dir = new File(_file_); if (!f_or_dir.exists()) throw new IllegalArgumentException(String.format("Input file or directory '%s' does not exist.", f_or_dir.getAbsolutePath())); if (f_or_dir.isFile()) throw new IllegalArgumentException( "Output directory must be provided when generating ngrams from file. Please provide a destination directory or generate ngrams from directory."); if (f_or_dir.isDirectory()) _index_dir = new File(f_or_dir, ".lmindex"); } String order = cmd.getOptionValue("cardinality", "1-5"); _accross_sentences_ = cmd.hasOption("accross_sentences"); if (_accross_sentences_ && cmd.getOptionValue("accross_sentences") != null) _accross_sentences_ = Boolean.parseBoolean(cmd.getOptionValue("accross_sentences")); int dash_index = order.indexOf('-'); _order_to_ = Integer.parseInt(order.substring(dash_index + 1, order.length()).trim()); _order_from_ = _order_to_; if (dash_index == 0) _order_from_ = 1; if (dash_index > 0) _order_from_ = Math.max(1, Integer.parseInt(order.substring(0, dash_index).trim())); _overwrite = cmd.hasOption("overwrite"); if (_overwrite && cmd.getOptionValue("overwrite") != null) _overwrite = Boolean.parseBoolean(cmd.getOptionValue("overwrite")); _mincount = Integer.parseInt(cmd.getOptionValue("mincount", "1")); } catch (Exception e) { CliUtils.print_usage_quit(System.err, Ngrams.class.getSimpleName(), opts, USAGE_HEADER, String.format("%s: %s%n", e.getClass().getSimpleName(), e.getMessage()), 1); } }
From source file:com.github.errantlinguist.latticevisualiser.ArgParser.java
/** * Creates and adds a lattice infile option to a given {@link Options} * object.// w w w . j a v a 2 s. co m * * @param options * The <code>Options</code> object to add to. */ private static void addLatticeInfileOption(final Options options) { OptionBuilder.isRequired(true); OptionBuilder.withLongOpt(LATTICE_INFILE_KEY_LONG); OptionBuilder.withDescription(LATTICE_INFILE_DESCR); OptionBuilder.hasArg(); OptionBuilder.withArgName(INFILE_ARG_NAME); OptionBuilder.withType(File.class); final Option latticeInfile = OptionBuilder.create(LATTICE_INFILE_KEY); options.addOption(latticeInfile); }
From source file:com.apkTool.Main.java
@SuppressWarnings("static-access") private static void _Options() { // create options Option versionOption = OptionBuilder.withLongOpt("version").withDescription("prints the version then exits") .create("version"); Option advanceOption = OptionBuilder.withLongOpt("advanced").withDescription("prints advance information.") .create("advance"); Option noSrcOption = OptionBuilder.withLongOpt("no-src").withDescription("Do not decode sources.") .create("s"); Option noResOption = OptionBuilder.withLongOpt("no-res").withDescription("Do not decode resources.") .create("r"); Option debugDecOption = OptionBuilder.withLongOpt("debug") .withDescription("REMOVED (DOES NOT WORK): Decode in debug mode.").create("d"); Option analysisOption = OptionBuilder.withLongOpt("match-original") .withDescription("Keeps files to closest to original as possible. Prevents rebuild.").create("m"); Option apiLevelOption = OptionBuilder.withLongOpt("api") .withDescription("The numeric api-level of the file to generate, e.g. 14 for ICS.").hasArg(true) .withArgName("API").create(); Option debugBuiOption = OptionBuilder.withLongOpt("debug") .withDescription("Sets android:debuggable to \"true\" in the APK's compiled manifest").create("d"); Option noDbgOption = OptionBuilder.withLongOpt("no-debug-info") .withDescription("don't write out debug info (.local, .param, .line, etc.)").create("b"); Option forceDecOption = OptionBuilder.withLongOpt("force") .withDescription("Force delete destination directory.").create("f"); Option frameTagOption = OptionBuilder.withLongOpt("frame-tag") .withDescription("Uses framework files tagged by <tag>.").hasArg(true).withArgName("tag") .create("t"); Option frameDirOption = OptionBuilder.withLongOpt("frame-path") .withDescription("Uses framework files located in <dir>.").hasArg(true).withArgName("dir") .create("p"); Option frameIfDirOption = OptionBuilder.withLongOpt("frame-path") .withDescription("Stores framework files into <dir>.").hasArg(true).withArgName("dir").create("p"); Option keepResOption = OptionBuilder.withLongOpt("keep-broken-res") .withDescription("Use if there was an error and some resources were dropped, e.g.\n" + " \"Invalid config flags detected. Dropping resources\", but you\n" + " want to decode them anyway, even with errors. You will have to\n" + " fix them manually before building.") .create("k"); Option forceBuiOption = OptionBuilder.withLongOpt("force-all") .withDescription("Skip changes detection and build all files.").create("f"); Option aaptOption = OptionBuilder.withLongOpt("aapt").hasArg(true).withArgName("loc") .withDescription("Loads aapt from specified location.").create("a"); Option originalOption = OptionBuilder.withLongOpt("copy-original") .withDescription(/*from ww w. j a v a 2 s . c o m*/ "Copies original AndroidManifest.xml and META-INF. See project page for more info.") .create("c"); Option tagOption = OptionBuilder.withLongOpt("tag").withDescription("Tag frameworks using <tag>.") .hasArg(true).withArgName("tag").create("t"); Option outputBuiOption = OptionBuilder.withLongOpt("output") .withDescription("The name of apk that gets written. Default is dist/name.apk").hasArg(true) .withArgName("dir").create("o"); Option outputDecOption = OptionBuilder.withLongOpt("output") .withDescription("The name of folder that gets written. Default is apk.out").hasArg(true) .withArgName("dir").create("o"); Option quietOption = OptionBuilder.withLongOpt("quiet").create("q"); Option verboseOption = OptionBuilder.withLongOpt("verbose").create("v"); // check for advance mode if (isAdvanceMode()) { DecodeOptions.addOption(noDbgOption); DecodeOptions.addOption(keepResOption); DecodeOptions.addOption(analysisOption); DecodeOptions.addOption(apiLevelOption); BuildOptions.addOption(debugBuiOption); BuildOptions.addOption(aaptOption); BuildOptions.addOption(originalOption); } // add global options normalOptions.addOption(versionOption); normalOptions.addOption(advanceOption); // add basic decode options DecodeOptions.addOption(frameTagOption); DecodeOptions.addOption(outputDecOption); DecodeOptions.addOption(frameDirOption); DecodeOptions.addOption(forceDecOption); DecodeOptions.addOption(noSrcOption); DecodeOptions.addOption(noResOption); // add basic build options BuildOptions.addOption(outputBuiOption); BuildOptions.addOption(frameDirOption); BuildOptions.addOption(forceBuiOption); // add basic framework options frameOptions.addOption(tagOption); frameOptions.addOption(frameIfDirOption); // add empty framework options emptyFrameworkOptions.addOption(forceDecOption); emptyFrameworkOptions.addOption(frameIfDirOption); // add all, loop existing cats then manually add advance for (Object op : normalOptions.getOptions()) { allOptions.addOption((Option) op); } for (Object op : DecodeOptions.getOptions()) { allOptions.addOption((Option) op); } for (Object op : BuildOptions.getOptions()) { allOptions.addOption((Option) op); } for (Object op : frameOptions.getOptions()) { allOptions.addOption((Option) op); } allOptions.addOption(analysisOption); allOptions.addOption(debugDecOption); allOptions.addOption(noDbgOption); allOptions.addOption(keepResOption); allOptions.addOption(debugBuiOption); allOptions.addOption(aaptOption); allOptions.addOption(originalOption); allOptions.addOption(verboseOption); allOptions.addOption(quietOption); }
From source file:com.linkedin.databus2.tools.dtail.DtailCliBase.java
@SuppressWarnings("static-access") @Override/*from w ww. j a va2 s.co m*/ protected void constructCommandLineOptions() { super.constructCommandLineOptions(); Option printVerbosityOption = OptionBuilder.withLongOpt(PRINT_VERBOSITY_OPT_NAME).hasArg() .withArgName("print_verbosity").withDescription("print verbosity: " + Arrays.toString(PrintVerbosity.values()) + "; default: " + DEFAULT_PRINT_VERBOSITY) .create(PRINT_VERBOSITY_OPT_CHAR); Option outputFormatOption = OptionBuilder.withLongOpt(OUTPUT_FORMAT_OPT_NAME).hasArg() .withArgName("output_format").withDescription("output format: " + Arrays.toString(OutputFormat.values()) + "; default: " + DEFAUL_OUTPUT_FORMAT) .create(OUTPUT_FORMAT_OPT_CHAR); Option outputOption = OptionBuilder.withLongOpt(OUTPUT_OPT_NAME).hasArg().withArgName("output_file") .withDescription("output file or - for STDOUT").create(OUTPUT_OPT_CHAR); Option resumeOption = OptionBuilder.withLongOpt(RESUME_OPT_NAME).hasArg().withArgName("checkpoint_dir") .withDescription("resumes from a previous checkpoint").create(); Option verboseOption = OptionBuilder.withLongOpt(VERBOSE_OPT_NAME) .withDescription("verbose logging: INFO or above").create(VERBOSE_OPT_CHAR); Option eventNumOption = OptionBuilder.withLongOpt(EVENT_NUM_OPT_NAME).hasArg().withArgName("num") .withDescription("max number of events to return; default: no limit").create(EVENT_NUM_OPT_CHAR); Option durationOption = OptionBuilder.withLongOpt(DURATION_OPTION_NAME).hasArg() .withArgName("duration_value") .withDescription("max consumption duration: value[ns|us|ms|s|min|hr|d]; default: no limit") .create(DURATION_OPTION_CHAR); Option statsOption = OptionBuilder.withLongOpt(STATS_OPT_NAME) .withDescription("print statistics at the end; Default: off").create(); Option sinceScnOption = OptionBuilder.withLongOpt(SCN_OPT_NAME).hasArg().withArgName("scn").withDescription( "starts consumption from the given scn; special values: BOB for current beginning of relay buffer, " + "EOB for current end of buffer; Default: BOB") .create(); _cliOptions.addOption(eventNumOption); _cliOptions.addOption(outputFormatOption); _cliOptions.addOption(outputOption); _cliOptions.addOption(printVerbosityOption); _cliOptions.addOption(resumeOption); _cliOptions.addOption(verboseOption); _cliOptions.addOption(durationOption); _cliOptions.addOption(statsOption); _cliOptions.addOption(sinceScnOption); }
From source file:com.linkedin.helix.mock.relay.DummyRelayProcess.java
@SuppressWarnings("static-access") private static Options constructCommandLineOptions() { Option helpOption = OptionBuilder.withLongOpt(help).withDescription("Prints command-line options info") .create();/* w ww . j ava2 s .co m*/ Option zkServerOption = OptionBuilder.withLongOpt(zkServer).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 hostOption = OptionBuilder.withLongOpt(hostAddress).withDescription("Provide host name").create(); hostOption.setArgs(1); hostOption.setRequired(true); hostOption.setArgName("Host name (Required)"); Option portOption = OptionBuilder.withLongOpt(hostPort).withDescription("Provide host port").create(); portOption.setArgs(1); portOption.setRequired(true); portOption.setArgName("Host port (Required)"); // add an option group including either --zkSvr or --configFile Option fileOption = OptionBuilder.withLongOpt(configFile) .withDescription("Provide file to read states/messages").create(); fileOption.setArgs(1); fileOption.setRequired(true); fileOption.setArgName("File to read states/messages (Optional)"); OptionGroup optionGroup = new OptionGroup(); optionGroup.addOption(zkServerOption); optionGroup.addOption(fileOption); Options options = new Options(); options.addOption(helpOption); // options.addOption(zkServerOption); options.addOption(clusterOption); options.addOption(hostOption); options.addOption(portOption); options.addOptionGroup(optionGroup); return options; }