Java Code Examples for org.apache.commons.cli.Option

The following code examples are extracted from open source projects. You can click to vote up the examples that are useful to you.

Example 1

From project Starfish, under directory /starfish/src/job_opt/edu/duke/starfish/jobopt/.

Source file: JobOptimizerDriver.java

  24 
vote

/** 
 * Specify properties of each optimizer option
 * @return the options
 */
@SuppressWarnings("static-access") private static Options buildOptimizerOptions(){
  Option modeOption=OptionBuilder.withArgName(MODE).hasArg().withDescription("Optimization mode options").create(MODE);
  Option profileOption=OptionBuilder.withArgName(PROFILE).hasArg().withDescription("The job profile file").create(PROFILE);
  Option confOption=OptionBuilder.withArgName(CONF).hasArg().withDescription("The job configuration file").create(CONF);
  Option schedulerOption=OptionBuilder.withArgName(SCHEDULER).hasArg().withDescription("The taskScheduler").create(SCHEDULER);
  Option inputOption=OptionBuilder.withArgName(INPUT).hasArg().withDescription("The input specifications file").create(INPUT);
  Option clusterOption=OptionBuilder.withArgName(CLUSTER).hasArg().withDescription("The cluster specifications file").create(CLUSTER);
  Option outputOption=OptionBuilder.withArgName("filepath").hasArg().withDescription("An output file to print to").create(OUTPUT);
  Option helpOption=OptionBuilder.withArgName("help").create(HELP);
  Options opts=new Options();
  opts.addOption(modeOption);
  opts.addOption(profileOption);
  opts.addOption(confOption);
  opts.addOption(schedulerOption);
  opts.addOption(inputOption);
  opts.addOption(clusterOption);
  opts.addOption(outputOption);
  opts.addOption(helpOption);
  return opts;
}
 

Example 2

From project activemq-apollo, under directory /apollo-util/src/main/scala/org/apache/activemq/apollo/util/cli/.

Source file: OptionBuilder.java

  22 
vote

public Option op(){
  Option option=new Option(id != null ? id : " ",description);
  option.setLongOpt(name);
  option.setRequired(required);
  option.setOptionalArg(optional);
  option.setType(type);
  option.setValueSeparator(sperator);
  if (arg != null && args == -1) {
    args=1;
  }
  option.setArgs(args);
  option.setArgName(arg);
  return option;
}
 

Example 3

From project ANNIS, under directory /annis-service/src/main/java/annis/administration/.

Source file: AnnisAdminRunner.java

  22 
vote

public OptionBuilder addRequiredParameter(String opt,String longOpt,String description){
  Option option=new Option(opt,longOpt,true,description);
  option.setRequired(true);
  options.addOption(option);
  return this;
}
 

Example 4

From project Chess_1, under directory /src/main/java/com/es/.

Source file: CmdConfiguration.java

  22 
vote

public CmdConfiguration(){
  this.options=new Options();
  @SuppressWarnings("static-access") final Option fileOption=OptionBuilder.withLongOpt("PGN_FILE").hasArg().withArgName("game.pgn").withDescription("PGN file including a full or partial game. Default is none.").create("f");
  @SuppressWarnings("static-access") final Option transOption=OptionBuilder.withLongOpt(TRANSPOSITION_TABLE_SIZE).hasArg().withDescription("The number of boards to store in the transposition table. Default is 100,000").create("t");
  @SuppressWarnings("static-access") final Option modeOption=OptionBuilder.withLongOpt(MODE).hasArg().withDescription("The mode to run the engine in: GUI or UCI. Default is GUI.").create("m");
  @SuppressWarnings("static-access") final Option depthOption=OptionBuilder.withLongOpt(DEPTH).hasArg().withDescription("The number of nodes to search").create("d");
  options.addOption(fileOption);
  options.addOption(transOption);
  options.addOption(modeOption);
  options.addOption(depthOption);
  options.addOption(new Option("h","help",false,"Print this help message"));
}
 

Example 5

From project hawtjni, under directory /hawtjni-generator/src/main/java/org/fusesource/hawtjni/generator/util/.

Source file: OptionBuilder.java

  22 
vote

public Option op(){
  Option option=new Option(id != null ? id : " ",description);
  option.setLongOpt(name);
  option.setRequired(required);
  option.setOptionalArg(optional);
  option.setType(type);
  option.setValueSeparator(sperator);
  if (arg != null && args == -1) {
    args=1;
  }
  option.setArgs(args);
  option.setArgName(arg);
  return option;
}
 

Example 6

From project hfind, under directory /src/main/java/com/ning/hfind/primary/.

Source file: OperandFactory.java

  22 
vote

public static Operand operandFromOption(PushbackIterator<Option> iterator){
  Option o=iterator.next();
  if (o.getOpt().equals(Find.OR)) {
    return new OrOperand();
  }
 else   if (o.getOpt().equals(Find.AND)) {
    return new AndOperand();
  }
 else {
    iterator.pushBack();
    return new AndOperand();
  }
}
 

Example 7

From project indextank-engine, under directory /src/main/java/com/flaptor/indextank/rpc/.

Source file: SearcherClient.java

  22 
vote

@SuppressWarnings("static-access") private static Options getOptions(){
  Option hostName=OptionBuilder.withArgName("server-host").hasArg().withDescription("the host where the server is running").withLongOpt("host").create("h");
  Option basePort=OptionBuilder.withArgName("base-port").hasArg().withDescription("The base port where the server is running").withLongOpt("port").create("p");
  Option function=OptionBuilder.withArgName("scoring-function").hasArg().withDescription("The scoring function index").withLongOpt("function").create("f");
  Option help=OptionBuilder.withDescription("displays this help").withLongOpt("help").create("help");
  Options options=new Options();
  options.addOption(hostName);
  options.addOption(basePort);
  options.addOption(function);
  options.addOption(help);
  return options;
}
 

Example 8

From project Ivory, under directory /client/src/main/java/org/apache/ivory/cli/.

Source file: IvoryCLI.java

  22 
vote

private Options createAdminOptions(){
  Options adminOptions=new Options();
  Option url=new Option(URL_OPTION,true,"Ivory URL");
  adminOptions.addOption(url);
  OptionGroup group=new OptionGroup();
  Option version=new Option(VERSION_OPTION,false,"show Ivory server build version");
  Option help=new Option("help",false,"show Ivory help");
  group.addOption(version);
  group.addOption(help);
  adminOptions.addOptionGroup(group);
  return adminOptions;
}
 

Example 9

From project Metamorphosis, under directory /metamorphosis-server-wrapper/src/main/java/com/taobao/metamorphosis/.

Source file: StartupHelp.java

  22 
vote

public static Options options(){
  final Options options=new Options();
  final Option brokerFile=new Option("f",true,"Broker configuration file path");
  brokerFile.setRequired(true);
  options.addOption(brokerFile);
  final Option pluginParams=OptionBuilder.withArgName("pluginname=configfile").hasArgs(2).withValueSeparator().withDescription("use value for given param").create("F");
  options.addOption(pluginParams);
  return options;
}
 

Example 10

From project mwe, under directory /plugins/org.eclipse.emf.mwe2.launch/src/org/eclipse/emf/mwe2/launch/runtime/.

Source file: Mwe2Launcher.java

  22 
vote

@SuppressWarnings("static-access") public Options getOptions(){
  final Options options=new Options();
  final Option paramOption=OptionBuilder.withArgName("key=value").withDescription("external property that is handled as workflow property").hasArgs().create(PARAM);
  paramOption.setLongOpt("param");
  options.addOption(paramOption);
  return options;
}
 

Example 11

From project parasim, under directory /applications/parasim-cli/src/main/java/org/sybila/parasim/application/cli/.

Source file: ParasimOptions.java

  22 
vote

public static Options getOptions(){
  if (options == null) {
    Option config=new Option("c","config",true,"specify config file, it uses 'parasim.xml' if not specified");
    config.setArgName("file");
    Option experiment=new Option("e","experiment",true,"specify experiment properties file");
    experiment.setArgName("file");
    Option result=new Option("r","result",false,"do not execute experiment, only print result");
    Option help=new Option("h","help",false,"show help");
    Option version=new Option("v","version",false,"show version");
    options=new Options().addOption(config).addOption(experiment).addOption(result).addOption(help).addOption(version);
  }
  return options;
}
 

Example 12

From project pluto, under directory /pluto-util/src/main/java/org/apache/pluto/util/cli/.

Source file: AssemblerCLI.java

  22 
vote

public AssemblerCLI(String[] args){
  this.args=args;
  options=new Options();
  Option destination=new Option("d","destination",true,"specify where the resulting webapp should be written ");
  destination.setArgName("file");
  Option debug=new Option("debug",false,"print debug information.");
  options.addOption(destination);
  options.addOption(debug);
}
 

Example 13

From project sqoop, under directory /src/java/org/apache/sqoop/cli/.

Source file: ToolOptions.java

  22 
vote

/** 
 * Flatten the different sets of related options into a single collection of options.
 * @return all options in the ToolOptions as a single set
 */
public Options merge(){
  Options mergedOpts=new Options();
  int totalOpts=0;
  for (  RelatedOptions relatedOpts : this) {
    for (    Object optObj : relatedOpts.getOptions()) {
      Option opt=(Option)optObj;
      mergedOpts.addOption(opt);
      totalOpts++;
    }
  }
  return mergedOpts;
}
 

Example 14

From project stackoverflow-java-sdk, under directory /core/src/examples/java/com/google/code/stackexchange/client/examples/.

Source file: AsyncApiExample.java

  22 
vote

/** 
 * Builds the options.
 * @return the options
 */
private static Options buildOptions(){
  Options opts=new Options();
  String helpMsg="Print this message.";
  Option help=new Option(HELP_OPTION,helpMsg);
  opts.addOption(help);
  String consumerKeyMsg="You API Key.";
  OptionBuilder.withArgName("key");
  OptionBuilder.hasArg();
  OptionBuilder.withDescription(consumerKeyMsg);
  Option consumerKey=OptionBuilder.create(APPLICATION_KEY_OPTION);
  opts.addOption(consumerKey);
  return opts;
}
 

Example 15

From project usergrid-stack, under directory /tools/src/main/java/org/usergrid/tools/.

Source file: ApiDoc.java

  22 
vote

@Override public Options createOptions(){
  Option generateWadl=OptionBuilder.create("wadl");
  Options options=new Options();
  options.addOption(generateWadl);
  return options;
}
 

Example 16

From project alphaportal_dev, under directory /sys-src/alphaportal_RESTClient/src/alpha/client/.

Source file: RESTClient.java

  21 
vote

/** 
 * Returns the Options of the CommandLine
 * @return returns the options of CommonCli
 */
@SuppressWarnings("static-access") private static Options getOptions(){
  OptionGroup group=new OptionGroup();
  Options options=new Options();
  Option help=new Option(OPTION_HELP,"help",false,"shows all possible options");
  Option debug=new Option(OPTION_DEBUG,false,"sets the Level of the Logging off");
  Option setHostName=OptionBuilder.withLongOpt("hostName").withArgName("HostID").hasArg().withDescription("sets the hostName ").create(OPTION_HOST);
  Option setCaseId=OptionBuilder.withLongOpt("caseID").withArgName("AlphaCaseID").hasArg().withDescription("sets the caseID ").create(OPTION_CASE);
  Option setCardId=OptionBuilder.withLongOpt("cardID").withArgName("AlphaCardID").hasArg().withDescription("sets the cardID ").create(OPTION_CARD);
  Option setContributorId=OptionBuilder.withLongOpt("contributerID").withArgName("ContributorID").hasArg().withDescription("sets the contributorID ").create(OPTION_CONTRIBUTOR);
  Option setAdornmentName=OptionBuilder.withLongOpt("adornmentName").withArgName("AdornmentName").hasArg().withDescription("sets the adornmentName ").create(OPTION_ADORNMENTNAME);
  Option setAdornmentValue=OptionBuilder.withLongOpt("adornmentValue").withArgName("AdornmentValue").hasArg().withDescription("sets the adornmentValue ").create(OPTION_ADORNMENTVALUE);
  Option setPayloadName=OptionBuilder.withLongOpt("payloadName").withArgName("PayloadName").hasArg().withDescription("sets the payloadName ").create(OPTION_PAYLOADNAME);
  Option setPayloadPath=OptionBuilder.withLongOpt("payloadPath").withArgName("PayloadPath").hasArg().withDescription("sets the payloadPath ").create(OPTION_PAYLOADPATH);
  Option setVersion=OptionBuilder.withLongOpt("version").withArgName("VersionID").hasArg().withDescription("sets the versionID ").create(OPTION_VERSION);
  options.addOption(setCaseId);
  options.addOption(setCardId);
  options.addOption(setContributorId);
  options.addOption(setAdornmentName);
  options.addOption(setAdornmentValue);
  options.addOption(setPayloadName);
  options.addOption(setPayloadPath);
  options.addOption(setVersion);
  options.addOption(setHostName);
  options.addOption(help);
  group.addOption(OptionBuilder.withDescription("adds an adornment or a payload").create(OPTION_ADD));
  group.addOption(OptionBuilder.withDescription("deletes an adornment or a payload").create(OPTION_DELETE));
  group.addOption(OptionBuilder.withDescription("gets an adornment or a payload").create(OPTION_GET));
  group.addOption(OptionBuilder.withDescription("sets an adornment or a payload").create(OPTION_SET));
  options.addOptionGroup(group);
  return options;
}
 

Example 17

From project archive-commons, under directory /ia-tools/src/main/java/org/archive/server/.

Source file: GZRangeClientTool.java

  21 
vote

private static Options buildOptions(){
  Options options=new Options();
  Option arcSize=new Option("as","arc-size",true,"stop writing records to ARCs after they grow beyond SIZE bytes");
  arcSize.setArgName("SIZE");
  Option warcSize=new Option("ws","warc-size",true,"stop writing records to WARCs after they grow beyond SIZE bytes");
  warcSize.setArgName("SIZE");
  Option warcHeaderFields=new Option("wf","warc-header-fields",true,"Read default WARC header fields from file PATH");
  warcHeaderFields.setArgName("PATH");
  Option timestamp=new Option("t","timestamp",true,"Use TIMESTAMP14 as the timestamp for W/ARC names, and for W/ARC header records.");
  timestamp.setArgName("TIMESTAMP14");
  Option errOnExit=new Option("e","exit-on-error",false,"if declared, a failure to get a single record causes a failure in the tool");
  options.addOption(arcSize);
  options.addOption(warcSize);
  options.addOption(warcHeaderFields);
  options.addOption(timestamp);
  options.addOption(errOnExit);
  return options;
}
 

Example 18

From project cw-omnibus, under directory /Push/GCMCommand/src/com/commonsware/android/gcm/cmd/.

Source file: GCM.java

  21 
vote

@SuppressWarnings("static-access") public static void main(String[] args){
  Option helpOpt=new Option("h","help",false,"print this message");
  Option apiKeyOpt=OptionBuilder.withArgName("key").hasArg().isRequired().withDescription("GCM API key").withLongOpt("apiKey").create('a');
  Option deviceOpt=OptionBuilder.withArgName("regId").hasArg().isRequired().withDescription("device to send to").withLongOpt("device").create('d');
  Option dataOpt=OptionBuilder.withArgName("key=value").hasArgs(2).withDescription("datum to send").withValueSeparator().withLongOpt("data").create('D');
  Options options=new Options();
  options.addOption(apiKeyOpt);
  options.addOption(deviceOpt);
  options.addOption(dataOpt);
  options.addOption(helpOpt);
  CommandLineParser parser=new PosixParser();
  try {
    CommandLine line=parser.parse(options,args);
    if (line.hasOption('h') || !line.hasOption('a') || !line.hasOption('d')) {
      HelpFormatter formatter=new HelpFormatter();
      formatter.printHelp("gcm",options,true);
    }
 else {
      sendMessage(line.getOptionValue('a'),Arrays.asList(line.getOptionValues('d')),line.getOptionProperties("data"));
    }
  }
 catch (  org.apache.commons.cli.MissingOptionException moe) {
    System.err.println("Invalid command syntax");
    HelpFormatter formatter=new HelpFormatter();
    formatter.printHelp("gcm",options,true);
  }
catch (  Exception e) {
    e.printStackTrace();
  }
}
 

Example 19

From project flume, under directory /flume-ng-channels/flume-file-channel/src/main/java/org/apache/flume/channel/file/.

Source file: CheckpointRebuilder.java

  21 
vote

public static void main(String[] args) throws Exception {
  Options options=new Options();
  Option opt=new Option("c",true,"checkpoint directory");
  opt.setRequired(true);
  options.addOption(opt);
  opt=new Option("l",true,"comma-separated list of log directories");
  opt.setRequired(true);
  options.addOption(opt);
  options.addOption(opt);
  opt=new Option("t",true,"capacity of the channel");
  opt.setRequired(true);
  options.addOption(opt);
  CommandLineParser parser=new GnuParser();
  CommandLine cli=parser.parse(options,args);
  File checkpointDir=new File(cli.getOptionValue("c"));
  String[] logDirs=cli.getOptionValue("l").split(",");
  List<File> logFiles=Lists.newArrayList();
  for (  String logDir : logDirs) {
    File[] files=new File(logDir).listFiles();
    logFiles.addAll(Arrays.asList(files));
  }
  int capacity=Integer.parseInt(cli.getOptionValue("t"));
  File checkpointFile=new File(checkpointDir,"checkpoint");
  if (checkpointFile.exists()) {
    LOG.error("Cannot execute fast replay",new IllegalStateException("Checkpoint exists" + checkpointFile));
  }
 else {
    EventQueueBackingStore backingStore=EventQueueBackingStoreFactory.get(checkpointFile,capacity,"channel");
    FlumeEventQueue queue=new FlumeEventQueue(backingStore,new File(checkpointDir,"inflighttakes"),new File(checkpointDir,"inflightputs"));
    CheckpointRebuilder rebuilder=new CheckpointRebuilder(logFiles,queue);
    if (rebuilder.rebuild()) {
      rebuilder.writeCheckpoint();
    }
 else {
      LOG.error("Could not rebuild the checkpoint due to errors.");
    }
  }
}
 

Example 20

From project genobyte, under directory /genobyte/src/main/java/org/obiba/genobyte/cli/.

Source file: BitwiseCli.java

  21 
vote

/** 
 * Adds a  {@link CliCommand} to the set of registered commands. If a commandwith the same short or long option string is already registered, an IllegalArgumentException is thrown.
 * @param command the command to register.
 * @throws IllegalArgumentException when a command with the same short option string already exists.
 */
public void registerCommand(CliCommand command){
  Option o=command.getOption();
  if (commandMap.containsKey(o.getLongOpt())) {
    throw new IllegalArgumentException("A command with key [" + o.getLongOpt() + "] is already registered.");
  }
  if (o.getOpt() != null) {
    for (    CliCommand c : commandMap.values()) {
      Option commandOption=c.getOption();
      if (commandOption.getOpt() != null && commandOption.getOpt().equals(o.getOpt())) {
        throw new IllegalArgumentException("Illegal option [" + o.getLongOpt() + "] conflicts with existing option ["+ commandOption.getLongOpt()+ "].");
      }
    }
  }
  commandMap.put(o.getLongOpt(),command);
  options.addOption(o);
  if (command.requiresOpenStore() == false) {
    noStoreOptions.addOption(o);
  }
}
 

Example 21

From project heritrix3, under directory /commons/src/main/java/org/archive/io/.

Source file: ArchiveReader.java

  21 
vote

/** 
 * @return Base Options object filled out with help, digest, strict, etc.options.
 */
protected static Options getOptions(){
  Options options=new Options();
  options.addOption(new Option("h","help",false,"Prints this message and exits."));
  options.addOption(new Option("o","offset",true,"Outputs record at this offset into file."));
  options.addOption(new Option("d","digest",true,"Pass true|false. Expensive. Default: true (SHA-1)."));
  options.addOption(new Option("s","strict",false,"Strict mode. Fails parse if incorrectly formatted file."));
  options.addOption(new Option("f","format",true,"Output options: 'cdx', cdxfile', 'dump', 'gzipdump'," + "'or 'nohead'. Default: 'cdx'."));
  return options;
}
 

Example 22

From project jackrabbit-oak, under directory /oak-mongomk-perf/src/main/java/org/apache/jackrabbit/mongomk/perf/.

Source file: MicroKernelPerf.java

  21 
vote

@SuppressWarnings("static-access") private static void evalCommandLineOptions(String[] args) throws Exception {
  Option log4jOption=OptionBuilder.withLongOpt("log4j-path").hasArg().withArgName("path").withDescription("path to a log4j config file").create("log4j");
  Option masterOption=OptionBuilder.withLongOpt("master-mode").withDescription("starts this in master mode").create("master");
  Option prepareOption=OptionBuilder.withLongOpt("prepare-environment").withDescription("resets the environment before executing").create("prep");
  Options options=new Options();
  options.addOption(log4jOption);
  options.addOption(masterOption);
  options.addOption(prepareOption);
  CommandLineParser parser=new GnuParser();
  CommandLine line=parser.parse(options,args);
  if (line.hasOption(log4jOption.getOpt())) {
    configLog4J(line.getOptionValue(log4jOption.getOpt()));
  }
  if (line.hasOption(masterOption.getOpt())) {
    masterMode=true;
  }
  if (line.hasOption(prepareOption.getOpt())) {
    prepareEnvironment=true;
  }
}
 

Example 23

From project jnrpe-lib, under directory /jnrpe-lib/src/main/java/it/jnrpe/plugins/.

Source file: PluginOption.java

  21 
vote

/** 
 * Convert this  {@link PluginOption} to the Option required by Apache.Commons Cli.
 * @return The option object required by commons cli
 */
Option toOption(){
  Option ret=new Option(m_sOption,m_sDescription);
  if (m_bArgsOptional != null) {
    ret.setOptionalArg(m_bArgsOptional.booleanValue());
  }
  if (m_bHasArgs) {
    if (m_iArgsCount == null) {
      ret.setArgs(Option.UNLIMITED_VALUES);
    }
  }
  ret.setRequired(m_bRequired);
  if (m_iArgsCount != null) {
    ret.setArgs(m_iArgsCount.intValue());
  }
  if (m_sArgName != null) {
    if (m_iArgsCount == null) {
      ret.setArgs(Option.UNLIMITED_VALUES);
    }
    ret.setArgName(m_sArgName);
  }
  if (m_sLongOpt != null) {
    ret.setLongOpt(m_sLongOpt);
  }
  if (m_sValueSeparator != null && m_sValueSeparator.length() != 0) {
    ret.setValueSeparator(m_sValueSeparator.charAt(0));
  }
  return ret;
}
 

Example 24

From project jnrpe-server, under directory /jnrpe-server/src/main/java/it/jnrpe/server/xml/.

Source file: XMLOption.java

  21 
vote

Option toOption(){
  Option ret=new Option(m_sOption,m_sDescription);
  if (m_bArgsOptional != null)   ret.setOptionalArg(m_bArgsOptional.booleanValue());
  if (m_bHasArgs) {
    if (m_iArgsCount == null)     ret.setArgs(Option.UNLIMITED_VALUES);
  }
  ret.setRequired(m_bRequired);
  if (m_iArgsCount != null)   ret.setArgs(m_iArgsCount.intValue());
  if (m_sArgName != null) {
    if (m_iArgsCount == null)     ret.setArgs(Option.UNLIMITED_VALUES);
    ret.setArgName(m_sArgName);
  }
  if (m_sLongOpt != null)   ret.setLongOpt(m_sLongOpt);
  if (m_sValueSeparator != null && m_sValueSeparator.length() != 0)   ret.setValueSeparator(m_sValueSeparator.charAt(0));
  return ret;
}
 

Example 25

From project Kairos, under directory /src/java/org/apache/nutch/indexer/field/.

Source file: AnchorFields.java

  21 
vote

/** 
 * Runs the AnchorFields job.
 */
public int run(String[] args) throws Exception {
  Options options=new Options();
  Option helpOpts=OptionBuilder.withArgName("help").withDescription("show this help message").create("help");
  Option outputOpts=OptionBuilder.withArgName("output").hasArg().withDescription("the output index directory").create("output");
  Option webGraphDbOpts=OptionBuilder.withArgName("webgraphdb").hasArg().withDescription("the webgraphdb to use").create("webgraphdb");
  Option basicFieldOpts=OptionBuilder.withArgName("basicfields").hasArgs().withDescription("the basicfields to use").create("basicfields");
  options.addOption(helpOpts);
  options.addOption(webGraphDbOpts);
  options.addOption(basicFieldOpts);
  options.addOption(outputOpts);
  CommandLineParser parser=new GnuParser();
  try {
    CommandLine line=parser.parse(options,args);
    if (line.hasOption("help") || !line.hasOption("webgraphdb") || !line.hasOption("output")|| !line.hasOption("basicfields")) {
      HelpFormatter formatter=new HelpFormatter();
      formatter.printHelp("AnchorFields",options);
      return -1;
    }
    String webGraphDb=line.getOptionValue("webgraphdb");
    String output=line.getOptionValue("output");
    String basicFields=line.getOptionValue("basicfields");
    createFields(new Path(webGraphDb),new Path(basicFields),new Path(output));
    return 0;
  }
 catch (  Exception e) {
    LOG.fatal("AnchorFields: " + StringUtils.stringifyException(e));
    return -2;
  }
}
 

Example 26

From project ManalithBot, under directory /ManalithBot/src/main/java/org/manalith/ircbot/plugin/curex/.

Source file: CurexInfoProvider.java

  21 
vote

/** 
 * Initiate org.apache.commons.cli based argument parser
 */
private void initArgumentParser(){
  optionList=new Options();
  Option help=new Option("help","show help messages");
  Option lastround=new Option("lastround","show latest updated date and time");
  Option currencyunit=new Option("unitlist","show the list of a currency unit");
  Option show=new Option("show","show the value on the currency exchance table.");
  show.setArgs(2);
  Option conv=new Option("conv","compute the value for the selected currency unit.");
  conv.setArgs(3);
  Option buycash=new Option("buycash","show the price when we buy the cache.");
  buycash.setArgs(2);
  Option cellcash=new Option("cellcash","show the price when we cell the cacle.");
  cellcash.setArgs(2);
  Option recvremit=new Option("recvremit","show the price when we receive the remittance.");
  recvremit.setArgs(2);
  Option sendremit=new Option("sendremit","show the price when we send the remittance");
  sendremit.setArgs(2);
  optionList.addOption(help);
  optionList.addOption(lastround);
  optionList.addOption(currencyunit);
  optionList.addOption(show);
  optionList.addOption(conv);
  optionList.addOption(buycash);
  optionList.addOption(cellcash);
  optionList.addOption(recvremit);
  optionList.addOption(sendremit);
  argParser=new GnuParser();
}
 

Example 27

From project mdk, under directory /apps/benchmark/src/main/java/uk/ac/ebi/apps/benchmark/.

Source file: ChemicalNameSearch.java

  21 
vote

@Override public void setupOptions(){
  add(new Option("i","input",true,"List of names to search (resource)"));
  add(new Option("f","input-file",true,"List of names to search (file)"));
  add(new Option("a","approximate",false,"Search using approximate match"));
  add(new Option("s","service",true,"Name service to use (chebi, kegg, metacyc, lipidmaps, hmdb, all)"));
  add(new Option("g","greedy",false,"Greedy Service searching (multiple services only)"));
}
 

Example 28

From project movsim, under directory /core/src/main/java/org/movsim/input/.

Source file: SimCommandLine.java

  21 
vote

/** 
 * Creates the options.
 */
private void createOptions(){
  options=new Options();
  options.addOption("h","help",false,"prints this message");
  options.addOption("d","validate",false,"parses xml input file for validation (without simulation)");
  options.addOption("i","internal_xml",false,"Writes internal xml (the simulation configuration) after validation from dtd. No simulation");
  options.addOption("w","write dtd",false,"writes dtd file to file");
  options.addOption("l","log",false,"writes the file \"log4j.properties\" to file to adjust the logging properties on an individual level");
  options.addOption("v","version",false,"prints version number of this movsim release");
  OptionBuilder.withArgName("file");
  OptionBuilder.hasArg();
  OptionBuilder.withDescription("argument has to be a xml file specifing the configuration of the simulation");
  final Option xmlSimFile=OptionBuilder.create("f");
  options.addOption(xmlSimFile);
  OptionBuilder.withArgName("directory");
  OptionBuilder.hasArg();
  OptionBuilder.withDescription("argument is the output path relative to calling directory");
  final Option outputPathOption=OptionBuilder.create("o");
  options.addOption(outputPathOption);
}
 

Example 29

From project nutch, under directory /src/java/org/apache/nutch/scoring/webgraph/.

Source file: LinkDumper.java

  21 
vote

/** 
 * Runs the LinkDumper tool.  This simply creates the database, to read the values the nested Reader tool must be used.
 */
public int run(String[] args) throws Exception {
  Options options=new Options();
  Option helpOpts=OptionBuilder.withArgName("help").withDescription("show this help message").create("help");
  Option webGraphDbOpts=OptionBuilder.withArgName("webgraphdb").hasArg().withDescription("the web graph database to use").create("webgraphdb");
  options.addOption(helpOpts);
  options.addOption(webGraphDbOpts);
  CommandLineParser parser=new GnuParser();
  try {
    CommandLine line=parser.parse(options,args);
    if (line.hasOption("help") || !line.hasOption("webgraphdb")) {
      HelpFormatter formatter=new HelpFormatter();
      formatter.printHelp("LinkDumper",options);
      return -1;
    }
    String webGraphDb=line.getOptionValue("webgraphdb");
    dumpLinks(new Path(webGraphDb));
    return 0;
  }
 catch (  Exception e) {
    LOG.error("LinkDumper: " + StringUtils.stringifyException(e));
    return -2;
  }
}
 

Example 30

From project rabbitmq-java-client, under directory /test/src/com/rabbitmq/client/test/performance/.

Source file: CLIHelper.java

  21 
vote

public static CLIHelper defaultHelper(){
  Options opts=new Options();
  opts.addOption(new Option("help","print this message"));
  opts.addOption(new Option("h","host",true,"broker host"));
  opts.addOption(new Option("p","port",true,"broker port"));
  return new CLIHelper(opts);
}
 

Example 31

From project spring-amqp, under directory /spring-rabbit/src/test/java/org/springframework/amqp/rabbit/.

Source file: MulticastMain.java

  21 
vote

private static Options getOptions(){
  Options options=new Options();
  options.addOption(new Option("?","help",false,"show usage"));
  options.addOption(new Option("h","host",true,"broker host"));
  options.addOption(new Option("p","port",true,"broker port"));
  options.addOption(new Option("t","type",true,"exchange type"));
  options.addOption(new Option("e","exchange",true,"exchange name"));
  options.addOption(new Option("i","interval",true,"sampling interval"));
  options.addOption(new Option("r","rate",true,"rate limit"));
  options.addOption(new Option("N","messages",true,"message count"));
  options.addOption(new Option("c","connections",false,"share consumer connections"));
  options.addOption(new Option("x","producers",true,"producer count"));
  options.addOption(new Option("y","consumers",true,"consumer count"));
  options.addOption(new Option("m","ptxsize",true,"producer tx size"));
  options.addOption(new Option("n","ctxsize",true,"consumer tx size"));
  options.addOption(new Option("a","autoack",false,"auto ack"));
  options.addOption(new Option("q","qos",true,"qos prefetch count"));
  options.addOption(new Option("s","size",true,"message size"));
  options.addOption(new Option("z","time",true,"time limit"));
  Option flag=new Option("f","flag",true,"message flag");
  flag.setArgs(Option.UNLIMITED_VALUES);
  options.addOption(flag);
  options.addOption(new Option("M","framemax",true,"frame max"));
  options.addOption(new Option("b","heartbeat",true,"heartbeat interval"));
  return options;
}
 

Example 32

From project SpringLS, under directory /src/main/java/com/springrts/springls/.

Source file: CmdLineArgs.java

  21 
vote

private static Options createOptions(){
  Configuration defaults=ServerConfiguration.getDefaults();
  Options options=new Options();
  Option help=new Option(null,"help",false,"Print this help message.");
  options.addOption(help);
  Option port=new Option("p","port",true,String.format("The main (TCP) port number to host on [1, 65535]." + " The default is %d.",defaults.getInt(ServerConfiguration.PORT)));
  port.setType(Number.class);
  port.setArgName("port-number");
  options.addOption(port);
  Option statistics=new Option(null,"statistics",false,"Whether to create and save statistics to disc on predefined" + " intervals.");
  options.addOption(statistics);
  Option natPort=new Option("n","nat-port",true,String.format("The (UDP) port number to host the NAT traversal techniques" + " help service on [1, 65535], which lets clients detect their" + " source port, for example when using \"hole punching\"."+ " The default is %d.",defaults.getInt(ServerConfiguration.NAT_PORT)));
  port.setType(Number.class);
  natPort.setArgName("NAT-port-number");
  options.addOption(natPort);
  Option logMain=new Option(null,"log-main",false,String.format("Whether to log all conversations from channel #main to \"%s\"",Channel.createDefaultActivityLogFilePath("main").getPath()));
  options.addOption(logMain);
  Option lanAdmin=new Option(null,"lan-admin",true,String.format("The LAN mode admin account. Use this account to administer" + " your LAN server. The default is \"%s\", with password \"%s\".",defaults.getString(ServerConfiguration.LAN_ADMIN_USERNAME),defaults.getString(ServerConfiguration.LAN_ADMIN_PASSWORD)));
  lanAdmin.setArgName("username");
  options.addOption(lanAdmin);
  Option loadArgs=new Option(null,"load-args",true,"Will read command-line arguments from the specified file." + " You can freely combine actual command-line arguments with" + " the ones from the file. If duplicate args are specified,"+ " the last one will prevail.");
  loadArgs.setArgName("filename");
  port.setType(File.class);
  options.addOption(loadArgs);
  Option springVersion=new Option(null,"spring-version",true,"Will set the latest Spring version to this string." + " The default is \"*\". This is used to tell clients which" + " version is the latest one, so that they know when to"+ " update.");
  springVersion.setArgName("version");
  options.addOption(springVersion);
  Option useStorageDb=new Option(null,"database",false,"Use a DB for user accounts and ban entries." + " This disables \"LAN mode\".");
  options.addOption(useStorageDb);
  Option useStorageFile=new Option(null,"file-storage",false,"Use the (deprecated) accounts.txt for user accounts." + " This disables \"LAN mode\".");
  options.addOption(useStorageFile);
  OptionGroup storageOG=new OptionGroup();
  storageOG.addOption(useStorageDb);
  storageOG.addOption(useStorageFile);
  options.addOptionGroup(storageOG);
  return options;
}
 

Example 33

From project Wikipedia-noSQL-Benchmark, under directory /src/de/zib/chordsharp/.

Source file: Main.java

  21 
vote

/** 
 * creates the options the command line should understand
 * @return the options the program understands
 */
private static Options getOptions(){
  Options options=new Options();
  OptionGroup group=new OptionGroup();
  options.addOption(new Option("help","print this message"));
  Option read=OptionBuilder.create("read");
  read.setArgName("key");
  read.setArgs(1);
  read.setDescription("read an item");
  group.addOption(read);
  Option write=OptionBuilder.create("write");
  write.setArgName("params");
  write.setArgs(2);
  write.setDescription("write an item: <key> <value>");
  group.addOption(write);
  Option publish=OptionBuilder.create("publish");
  publish.setArgName("params");
  publish.setArgs(2);
  publish.setDescription("publish a new message for a topic: <topic> <message>");
  group.addOption(publish);
  Option subscribe=OptionBuilder.create("subscribe");
  subscribe.setArgName("params");
  subscribe.setArgs(2);
  subscribe.setDescription("subscribe to a topic: <topic> <url>");
  group.addOption(subscribe);
  Option unsubscribe=OptionBuilder.create("unsubscribe");
  unsubscribe.setArgName("params");
  unsubscribe.setArgs(2);
  unsubscribe.setDescription("unsubscribe from a topic: <topic> <url>");
  group.addOption(unsubscribe);
  Option getSubscribers=OptionBuilder.create("getsubscribers");
  getSubscribers.setArgName("topic");
  getSubscribers.setArgs(1);
  getSubscribers.setDescription("get subscribers of a topic");
  group.addOption(getSubscribers);
  options.addOption(new Option("minibench","run mini benchmark"));
  options.addOptionGroup(group);
  return options;
}
 

Example 34

From project ServalMapsDataMan, under directory /src/org/servalproject/maps/dataman/.

Source file: DataManCli.java

  20 
vote

private static Options createOptions(){
  Options options=new Options();
  OptionBuilder.withArgName("path");
  OptionBuilder.hasArg(true);
  OptionBuilder.withDescription("path to the input file / directory");
  OptionBuilder.isRequired(true);
  options.addOption(OptionBuilder.create("input"));
  OptionBuilder.withArgName("path");
  OptionBuilder.hasArg(true);
  OptionBuilder.withDescription("path to the output file");
  OptionBuilder.isRequired(true);
  options.addOption(OptionBuilder.create("output"));
  OptionBuilder.withArgName("text");
  OptionBuilder.hasArg(true);
  OptionBuilder.withDescription("manipulation task to undertake");
  OptionBuilder.isRequired(true);
  options.addOption(OptionBuilder.create("task"));
  OptionBuilder.withArgName("text");
  OptionBuilder.hasArg(true);
  OptionBuilder.withDescription("style definition information");
  OptionBuilder.isRequired(false);
  options.addOption(OptionBuilder.create("style"));
  OptionBuilder.withArgName("text");
  OptionBuilder.hasArg(true);
  OptionBuilder.withDescription("files beginning with this pattern will be processed");
  OptionBuilder.isRequired(false);
  options.addOption(OptionBuilder.create("filter"));
  options.addOption(new Option("verbose","use verbose output"));
  return options;
}
 

Example 35

From project eclim, under directory /org.eclim/java/org/eclim/command/.

Source file: CommandLine.java

  19 
vote

/** 
 * Constructs a new instance from the supplied command line.
 * @param command The command.
 * @param commandLine The command line.
 * @param args The orginal command line args.
 */
public CommandLine(Command command,org.apache.commons.cli.CommandLine commandLine,String[] args){
  this.command=command;
  this.args=args;
  Option[] options=commandLine.getOptions();
  for (  Option option : options) {
    if (option.hasArgs()) {
      this.options.put(option.getOpt(),commandLine.getOptionValues(option.getOpt()));
    }
 else {
      this.options.put(option.getOpt(),commandLine.getOptionValue(option.getOpt()));
    }
  }
  unrecognized=commandLine.getArgs();
}
 

Example 36

From project joshua, under directory /src/joshua/subsample/.

Source file: AlignedSubsampler.java

  19 
vote

@SuppressWarnings("static-access") public static void main(String[] args){
  new SubsamplerCLI(){
    protected final Option oa=OptionBuilder.withArgName("lang").hasArg().withDescription("Word alignment extension").isRequired().create("a");
    protected final Option oapath=OptionBuilder.withArgName("path").hasArg().withDescription("Directory containing word alignment files").create("apath");
    public Options getCliOptions(){
      return super.getCliOptions().addOption(oa).addOption(oapath);
    }
    public String getClassName(){
      return AlignedSubsampler.class.getName();
    }
    public void runSubsampler(    String[] testFiles,    int maxN,    int targetCount,    float ratio) throws IOException {
      new AlignedSubsampler(testFiles,maxN,targetCount).subsample(ot.getValue(),ratio,of.getValue(),oe.getValue(),oa.getValue(),ofpath.getValue(),oepath.getValue(),oapath.getValue(),ooutput.getValue());
    }
  }
.runMain(args);
}
 

Example 37

From project Lily, under directory /apps/tester/src/main/java/org/lilyproject/tools/tester/.

Source file: Tester.java

  19 
vote

@Override public List<Option> getOptions(){
  List<Option> options=super.getOptions();
  configFileOption=OptionBuilder.withArgName("config.json").hasArg().withDescription("Test tool configuration file").withLongOpt("config").create("c");
  options.add(configFileOption);
  dumpSampleConfigOption=OptionBuilder.withDescription("Dumps a sample configuration to standard out.").withLongOpt("dump-sample-config").create("d");
  options.add(dumpSampleConfigOption);
  logDirOption=OptionBuilder.withArgName("logDir").hasArg().withDescription("Directory to put the logfiles into.").withLongOpt("logdir").create("l");
  options.add(logDirOption);
  return options;
}
 

Example 38

From project onebusaway-gtfs-modules, under directory /onebusaway-gtfs-merge-cli/src/main/java/org/onebusaway/gtfs_merge/.

Source file: GtfsMergerMain.java

  19 
vote

private void processOptions(CommandLine cli,GtfsMerger merger){
  OptionHandler currentOptionHandler=null;
  AbstractEntityMergeStrategy mergeStrategy=null;
  for (  Option option : cli.getOptions()) {
    if (option.getOpt().equals(ARG_FILE)) {
      String filename=option.getValue();
      Class<?> entityClass=_entityClassesByFilename.get(filename);
      if (entityClass == null) {
        throw new IllegalStateException("unknown GTFS filename: " + filename);
      }
      mergeStrategy=getMergeStrategyForEntityClass(entityClass,merger);
      currentOptionHandler=getOptionHandlerForEntityClass(entityClass);
    }
 else {
      if (currentOptionHandler == null) {
        throw new IllegalArgumentException("you must specify a --file argument first before specifying file-specific arguments");
      }
      currentOptionHandler.handleOption(option,mergeStrategy);
    }
  }
}
 

Example 39

From project scoutdoc, under directory /main/src/scoutdoc/main/.

Source file: Main.java

  19 
vote

private static <T extends Enum<T>>List<T> readOptionEnum(CommandLine cmd,Option option,Class<T> c) throws MissingArgumentException {
  List<T> operations=Lists.newArrayList();
  for (  String name : cmd.getOptionValues(option.getOpt())) {
    try {
      T operation=Enum.valueOf(c,name);
      operations.add(operation);
    }
 catch (    IllegalArgumentException e) {
      throw new MissingArgumentException("Unknown value '" + name + "' for '--"+ option.getLongOpt()+ "'");
    }
  }
  return operations;
}