List of usage examples for org.apache.commons.cli PatternOptionBuilder NUMBER_VALUE
Class NUMBER_VALUE
To view the source code for org.apache.commons.cli PatternOptionBuilder NUMBER_VALUE.
Click Source Link
From source file:de.haber.xmind2latex.cli.CliOptionBuilder.java
@SuppressWarnings("static-access") /**//from w w w.jav a 2s. c om * * @return the CLI options for the XMindToLatex exporter. */ protected static Options getOptions() { Options o = new Options(); o.addOption(OptionBuilder.withArgName("input file").withLongOpt("input") .withDescription("Required input file name.").hasArg(true).isRequired(false) .withType(PatternOptionBuilder.FILE_VALUE).create(INPUT)); o.addOption(OptionBuilder.withArgName("force").withLongOpt("force") .withDescription("Force overwrite existing files (optional).").hasArg(false).isRequired(false) .create(FORCE)); o.addOption(OptionBuilder.withArgName("output file").withLongOpt("output") .withDescription("Output file name (optional). Default output file is \"<input file>.tex.\"") .hasArg().isRequired(false).withType(PatternOptionBuilder.FILE_VALUE).create(OUTPUT)); o.addOption(OptionBuilder.withArgName("template level").withLongOpt("template-level") .withDescription("Maximal level for template usage.").hasArg().isRequired(false) .withType(PatternOptionBuilder.NUMBER_VALUE).create(TEMPLATE_LEVEL)); o.addOption(OptionBuilder.withArgName("help").withLongOpt("help") .withDescription("Prints this help message.").hasArg(false).isRequired(false).create(HELP)); o.addOption(OptionBuilder.withArgName("level> <start> <end").withLongOpt("env").hasArgs(3) .withDescription("Sets the start and end environment templates for the given level (optional). " + "Templates must be either loadable from the classpath with the given full qualified name (no file extension, " + "directories separated by a '.', or as a file (with '.ftl' extension, directories separated by a path separator).") .isRequired(false).create(ENVIRONMENT)); o.addOption(OptionBuilder.withArgName("level> <template").withLongOpt("level-template") .withValueSeparator(' ') .withDescription("Sets the template that is to be used for the given level (optional). " + "Templates must be either loadable from the classpath with the given full qualified name (no file extension, " + "directories separated by a '.', or as a file (with '.ftl' extension, directories separated by a path separator).") .hasArgs(2).isRequired(false).create(LEVEL)); o.addOption(OptionBuilder.withArgName("version").withLongOpt("version") .withDescription("Prints the version.").hasArg(false).isRequired(false).create(VERSION)); return o; }
From source file:com.flaptor.hounder.indexer.RmiIndexerStub.java
@SuppressWarnings("static-access") private static Options getOptions() { Option host = OptionBuilder.withArgName("hostName").hasArg() .withDescription("the hostname where the indexer is running").isRequired().withLongOpt("host") .create("h"); Option port = OptionBuilder.withArgName("basePort").hasArg() .withDescription("the basePort where the indexer is running").isRequired() .withType(PatternOptionBuilder.NUMBER_VALUE).withLongOpt("port").create("p"); Option delUrl = OptionBuilder.withArgName("url").hasArg().withDescription("a url to delete on the indexer") .withLongOpt("deleteUrl").create("du"); Option delFile = OptionBuilder.withArgName("url-file").hasArg() .withDescription("a file containing urls to delete on the indexer").withLongOpt("deleteFile") .create("df"); Option optimize = new Option("o", "optimize", false, "send optimize command to indexer"); Option checkpoint = new Option("c", "checkpoint", false, "send checkpoint (and push) command to indexer"); Option stop = new Option("s", "stop", false, "send stop command to indexer"); Options options = new Options(); options.addOption(host);/*from w w w .j a va 2s. co m*/ options.addOption(port); options.addOption(delUrl); options.addOption(delFile); options.addOption(optimize); options.addOption(checkpoint); options.addOption(stop); return options; }
From source file:org.apache.ambari.servicemonitor.utils.OptionHelper.java
/** * Add an option that is followed by an integer argument * @param options options to add it to/*from www . j a v a 2 s. c o m*/ * @param shortName short option name * @param longName long option name * @param description description * @return an option that is already added to the option set */ public static Option addIntOpt(Options options, String shortName, String longName, String description) { Option option = new Option(shortName, longName, true, description); option.setType(PatternOptionBuilder.NUMBER_VALUE); options.addOption(option); return option; }
From source file:org.apache.hadoop.hbase.client.HBaseFsck.java
/** * Main program// www . j ava2 s.co m * * @param args * @throws ParseException */ public static void main(String[] args) throws IOException, MasterNotRunningException, InterruptedException, ParseException { Options opt = new Options(); opt.addOption(OptionBuilder.withArgName("property=value").hasArg() .withDescription("Override HBase Configuration Settings").create("D")); opt.addOption(OptionBuilder.withArgName("timeInSeconds").hasArg() .withDescription("Ignore regions with metadata updates in the last {timeInSeconds}.") .withType(PatternOptionBuilder.NUMBER_VALUE).create("timelag")); opt.addOption(OptionBuilder.withArgName("timeInSeconds").hasArg() .withDescription("Stop scan jobs after a fixed time & analyze existing data.") .withType(PatternOptionBuilder.NUMBER_VALUE).create("timeout")); opt.addOption("fix", false, "Try to fix some of the errors."); opt.addOption("y", false, "Do not prompt for reconfirmation from users on fix."); opt.addOption("w", false, "Try to fix warnings as well as errors."); opt.addOption("summary", false, "Print only summary of the tables and status."); opt.addOption("detail", false, "Display full report of all regions."); opt.addOption("checkRegionInfo", false, "Check if .regioninfo is consistent with .META."); opt.addOption("h", false, "Display this help"); CommandLine cmd = new GnuParser().parse(opt, args); // any unknown args or -h if (!cmd.getArgList().isEmpty() || cmd.hasOption("h")) { new HelpFormatter().printHelp("hbck", opt); return; } Configuration conf = HBaseConfiguration.create(); conf.set("fs.defaultFS", conf.get("hbase.rootdir")); if (cmd.hasOption("D")) { for (String confOpt : cmd.getOptionValues("D")) { String[] kv = confOpt.split("=", 2); if (kv.length == 2) { conf.set(kv[0], kv[1]); LOG.debug("-D configuration override: " + kv[0] + "=" + kv[1]); } else { throw new ParseException("-D option format invalid: " + confOpt); } } } if (cmd.hasOption("timeout")) { Object timeout = cmd.getParsedOptionValue("timeout"); if (timeout instanceof Long) { conf.setLong(HConstants.HBASE_RPC_TIMEOUT_KEY, ((Long) timeout).longValue() * 1000); } else { throw new ParseException("-timeout needs a long value."); } } // create a fsck object HBaseFsck fsck = new HBaseFsck(conf); fsck.setTimeLag(HBaseFsckRepair.getEstimatedFixTime(conf)); if (cmd.hasOption("details")) { fsck.displayFullReport(); } if (cmd.hasOption("timelag")) { Object timelag = cmd.getParsedOptionValue("timelag"); if (timelag instanceof Long) { fsck.setTimeLag(((Long) timelag).longValue() * 1000); } else { throw new ParseException("-timelag needs a long value."); } } if (cmd.hasOption("fix")) { fsck.setFixState(FixState.ERROR); } if (cmd.hasOption("w")) { fsck.setFixState(FixState.ALL); } if (cmd.hasOption("y")) { fsck.setPromptResponse(true); } if (cmd.equals("summary")) { fsck.setSummary(); } if (cmd.hasOption("checkRegionInfo")) { checkRegionInfo = true; } int code = -1; try { // do the real work of fsck code = fsck.doWork(); // If we have tried to fix the HBase state, run fsck again // to see if we have fixed our problems if (fsck.shouldRerun()) { fsck.setFixState(FixState.NONE); long fixTime = HBaseFsckRepair.getEstimatedFixTime(conf); if (fixTime > 0) { LOG.info("Waiting " + StringUtils.formatTime(fixTime) + " before checking to see if fixes worked..."); Thread.sleep(fixTime); } code = fsck.doWork(); } } catch (InterruptedException ie) { LOG.info("HBCK was interrupted by user. Exiting..."); code = -1; } Runtime.getRuntime().exit(code); }
From source file:org.dcm4che.tool.dcm2dcm.Dcm2Dcm.java
@SuppressWarnings("static-access") private static CommandLine parseComandLine(String[] args) throws ParseException { Options opts = new Options(); CLIUtils.addCommonOptions(opts);/* w w w .j a v a 2 s .co m*/ CLIUtils.addEncodingOptions(opts); OptionGroup tsGroup = new OptionGroup(); tsGroup.addOption(OptionBuilder.withLongOpt("transfer-syntax").hasArg().withArgName("uid") .withDescription(rb.getString("transfer-syntax")).create("t")); tsGroup.addOption(OptionBuilder.withLongOpt("jpeg").withDescription(rb.getString("jpeg")).create()); tsGroup.addOption(OptionBuilder.withLongOpt("jpll").withDescription(rb.getString("jpll")).create()); tsGroup.addOption(OptionBuilder.withLongOpt("jpls").withDescription(rb.getString("jpls")).create()); tsGroup.addOption(OptionBuilder.withLongOpt("j2kr").withDescription(rb.getString("j2kr")).create()); tsGroup.addOption(OptionBuilder.withLongOpt("j2ki").withDescription(rb.getString("j2ki")).create()); opts.addOptionGroup(tsGroup); OptionGroup fmiGroup = new OptionGroup(); fmiGroup.addOption(OptionBuilder.withLongOpt("no-fmi").withDescription(rb.getString("no-fmi")).create("F")); fmiGroup.addOption( OptionBuilder.withLongOpt("retain-fmi").withDescription(rb.getString("retain-fmi")).create("f")); opts.addOptionGroup(fmiGroup); opts.addOption(OptionBuilder.hasArg().withArgName("max-error").withType(PatternOptionBuilder.NUMBER_VALUE) .withDescription(rb.getString("verify")).withLongOpt("verify").create()); opts.addOption(OptionBuilder.hasArg().withArgName("size").withType(PatternOptionBuilder.NUMBER_VALUE) .withDescription(rb.getString("verify-block")).withLongOpt("verify-block").create()); opts.addOption(OptionBuilder.hasArg().withArgName("quality").withType(PatternOptionBuilder.NUMBER_VALUE) .withDescription(rb.getString("quality")).create("q")); opts.addOption( OptionBuilder.hasArg().withArgName("encoding-rate").withType(PatternOptionBuilder.NUMBER_VALUE) .withDescription(rb.getString("encoding-rate")).create("Q")); opts.addOption(OptionBuilder.hasArgs().withArgName("name=value").withValueSeparator() .withDescription(rb.getString("compression-param")).create("C")); CommandLine cl = CLIUtils.parseComandLine(args, opts, rb, Dcm2Dcm.class); return cl; }
From source file:org.dcm4che.tool.dcm2jpg.Dcm2Jpg.java
@SuppressWarnings("static-access") private static CommandLine parseComandLine(String[] args) throws ParseException { Options opts = new Options(); CLIUtils.addCommonOptions(opts);/*from w w w .j av a2 s .c o m*/ opts.addOption( OptionBuilder.hasArg().withArgName("format").withDescription(rb.getString("format")).create("F")); opts.addOption( OptionBuilder.hasArg().withArgName("class").withDescription(rb.getString("encoder")).create("E")); opts.addOption(OptionBuilder.hasArg().withArgName("type").withDescription(rb.getString("compression")) .create("C")); opts.addOption(OptionBuilder.hasArg().withArgName("quality").withType(PatternOptionBuilder.NUMBER_VALUE) .withDescription(rb.getString("quality")).create("q")); opts.addOption(OptionBuilder.hasArg().withArgName("suffix").withDescription(rb.getString("suffix")) .withLongOpt("suffix").create()); opts.addOption(OptionBuilder.hasArg().withArgName("number").withType(PatternOptionBuilder.NUMBER_VALUE) .withDescription(rb.getString("frame")).withLongOpt("frame").create()); opts.addOption(OptionBuilder.hasArg().withArgName("center").withType(PatternOptionBuilder.NUMBER_VALUE) .withDescription(rb.getString("windowCenter")).withLongOpt("windowCenter").create("c")); opts.addOption(OptionBuilder.hasArg().withArgName("width").withType(PatternOptionBuilder.NUMBER_VALUE) .withDescription(rb.getString("windowWidth")).withLongOpt("windowWidth").create("w")); opts.addOption(OptionBuilder.hasArg().withArgName("number").withType(PatternOptionBuilder.NUMBER_VALUE) .withDescription(rb.getString("window")).withLongOpt("window").create()); opts.addOption(OptionBuilder.hasArg().withArgName("number").withType(PatternOptionBuilder.NUMBER_VALUE) .withDescription(rb.getString("voilut")).withLongOpt("voilut").create()); opts.addOption(OptionBuilder.hasArg().withArgName("file").withType(PatternOptionBuilder.EXISTING_FILE_VALUE) .withDescription(rb.getString("ps")).withLongOpt("ps").create()); opts.addOption(OptionBuilder.hasArg().withArgName("mask").withDescription(rb.getString("overlays")) .withLongOpt("overlays").create()); opts.addOption(OptionBuilder.hasArg().withArgName("value").withDescription(rb.getString("ovlygray")) .withLongOpt("ovlygray").create()); opts.addOption(null, "uselut", false, rb.getString("uselut")); opts.addOption(null, "noauto", false, rb.getString("noauto")); opts.addOption(null, "lsE", false, rb.getString("lsencoders")); opts.addOption(null, "lsF", false, rb.getString("lsformats")); CommandLine cl = CLIUtils.parseComandLine(args, opts, rb, Dcm2Jpg.class); if (cl.hasOption("lsF")) { listSupportedFormats(); System.exit(0); } if (cl.hasOption("lsE")) { listSupportedImageWriters(cl.getOptionValue("F", "JPEG")); System.exit(0); } return cl; }