Example usage for org.apache.commons.cli OptionBuilder hasArg

List of usage examples for org.apache.commons.cli OptionBuilder hasArg

Introduction

In this page you can find the example usage for org.apache.commons.cli OptionBuilder hasArg.

Prototype

public static OptionBuilder hasArg() 

Source Link

Document

The next Option created will require an argument value.

Usage

From source file:com.google.code.uclassify.client.examples.ClassifierExample.java

/**
 * Build command line options object./*from   w  w w  .j  a v a 2  s . c o m*/
 * 
 * @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 Write Key.";
    OptionBuilder.withArgName("readKey");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription(consumerKeyMsg);
    Option consumerKey = OptionBuilder.create(WRITE_KEY);
    opts.addOption(consumerKey);

    String idMsg = "Classifier Name";
    OptionBuilder.withArgName("classifier");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription(idMsg);
    Option id = OptionBuilder.create(CLASSIFIER);
    opts.addOption(id);

    return opts;
}

From source file:chibi.gemmaanalysis.cli.deprecated.BioSequenceCleanupCli.java

@SuppressWarnings("static-access")
@Override// w  w  w  . j a  v a2s. c  o  m
protected void buildOptions() {
    super.buildOptions();
    Option justTestingOption = OptionBuilder.withDescription("Set to run without any database modifications")
            .create("dryrun");
    addOption(justTestingOption);

    Option sequenceNameList = OptionBuilder.hasArg().withArgName("file")
            .withDescription("File with list of biosequence ids to check.").create('b');
    addOption(sequenceNameList);
}

From source file:edu.harvard.med.iccbl.screensaver.io.AdminEmailApplication.java

@SuppressWarnings("static-access")
public AdminEmailApplication(String[] cmdLineArgs) {
    super(cmdLineArgs);

    addCommandLineOption(OptionBuilder.hasArg().withArgName(EMAIL_RECIPIENT_LIST_OPTION[ARG_INDEX])
            .withDescription(EMAIL_RECIPIENT_LIST_OPTION[DESCRIPTION_INDEX])
            .withLongOpt(EMAIL_RECIPIENT_LIST_OPTION[LONG_OPTION_INDEX])
            .create(EMAIL_RECIPIENT_LIST_OPTION[SHORT_OPTION_INDEX]));
    addCommandLineOption(OptionBuilder.withDescription(NO_NOTIFY_OPTION[DESCRIPTION_INDEX])
            .withLongOpt(NO_NOTIFY_OPTION[LONG_OPTION_INDEX]).create(NO_NOTIFY_OPTION[SHORT_OPTION_INDEX]));
    addCommandLineOption(OptionBuilder.withDescription(TEST_EMAIL_ONLY[DESCRIPTION_INDEX])
            .withLongOpt(TEST_EMAIL_ONLY[LONG_OPTION_INDEX]).create(TEST_EMAIL_ONLY[SHORT_OPTION_INDEX]));
    addCommandLineOption(OptionBuilder.withDescription(EMAIL_DSL_ADMINS_ONLY[DESCRIPTION_INDEX])
            .withLongOpt(EMAIL_DSL_ADMINS_ONLY[LONG_OPTION_INDEX])
            .create(EMAIL_DSL_ADMINS_ONLY[SHORT_OPTION_INDEX]));
}

From source file:com.beaconhill.s3cp.CmdLine.java

Options buildOptions() {
    Options options = new Options();

    Option helpOption = OptionBuilder.withDescription("Help").withLongOpt("help").isRequired(false).create("h");

    Option accountNameOption = OptionBuilder.hasArg().withDescription("Account Name [OPTIONAL]")
            .withLongOpt("account-name").isRequired(false).create("a");

    options.addOption(helpOption);/*from  w w w  . j a  v  a  2s .  c o  m*/
    options.addOption(accountNameOption);
    return options;
}

From source file:com.google.code.linkedinapi.client.examples.PostCommentExample.java

/**
  * Build command line options object.//from w ww .  j a  va  2 s .  c  o m
  */
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 Consumer Key.";
    OptionBuilder.withArgName("consumerKey");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription(consumerKeyMsg);
    Option consumerKey = OptionBuilder.create(CONSUMER_KEY_OPTION);
    opts.addOption(consumerKey);

    String consumerSecretMsg = "You API Consumer Secret.";
    OptionBuilder.withArgName("consumerSecret");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription(consumerSecretMsg);
    Option consumerSecret = OptionBuilder.create(CONSUMER_SECRET_OPTION);
    opts.addOption(consumerSecret);

    String accessTokenMsg = "You OAuth Access Token.";
    OptionBuilder.withArgName("accessToken");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription(accessTokenMsg);
    Option accessToken = OptionBuilder.create(ACCESS_TOKEN_OPTION);
    opts.addOption(accessToken);

    String tokenSecretMsg = "You OAuth Access Token Secret.";
    OptionBuilder.withArgName("accessTokenSecret");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription(tokenSecretMsg);
    Option accessTokenSecret = OptionBuilder.create(ACCESS_TOKEN_SECRET_OPTION);
    opts.addOption(accessTokenSecret);

    String idMsg = "ID of the post on which to comment.";
    OptionBuilder.withArgName("postId");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription(idMsg);
    Option id = OptionBuilder.create(POST_ID_OPTION);
    opts.addOption(id);

    String commentMsg = "Text of the comment.";
    OptionBuilder.withArgName("comment");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription(commentMsg);
    Option comment = OptionBuilder.create(COMMENT_TEXT_OPTION);
    opts.addOption(comment);

    return opts;
}

From source file:com.google.code.linkedinapi.client.examples.PostShareExample.java

/**
  * Build command line options object./*ww  w .j  a v a2 s.  com*/
  */
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 Consumer Key.";
    OptionBuilder.withArgName("consumerKey");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription(consumerKeyMsg);
    Option consumerKey = OptionBuilder.create(CONSUMER_KEY_OPTION);
    opts.addOption(consumerKey);

    String consumerSecretMsg = "You API Consumer Secret.";
    OptionBuilder.withArgName("consumerSecret");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription(consumerSecretMsg);
    Option consumerSecret = OptionBuilder.create(CONSUMER_SECRET_OPTION);
    opts.addOption(consumerSecret);

    String accessTokenMsg = "You OAuth Access Token.";
    OptionBuilder.withArgName("accessToken");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription(accessTokenMsg);
    Option accessToken = OptionBuilder.create(ACCESS_TOKEN_OPTION);
    opts.addOption(accessToken);

    String tokenSecretMsg = "You OAuth Access Token Secret.";
    OptionBuilder.withArgName("accessTokenSecret");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription(tokenSecretMsg);
    Option accessTokenSecret = OptionBuilder.create(ACCESS_TOKEN_SECRET_OPTION);
    opts.addOption(accessTokenSecret);

    String statusMsg = "Text of the share.";
    OptionBuilder.withArgName("share");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription(statusMsg);
    Option status = OptionBuilder.create(SHARE_TEXT_OPTION);
    opts.addOption(status);

    String urlMsg = "URL to be shared.";
    OptionBuilder.withArgName("url");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription(urlMsg);
    Option url = OptionBuilder.create(URL_OPTION);
    opts.addOption(url);

    return opts;
}

From source file:com.google.code.stackexchange.client.examples.AsyncApiExample.java

/**
 * Builds the options.// w  w  w.j a  v a  2s .  c om
 * 
 * @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;
}

From source file:com.google.code.linkedinapi.client.examples.PostStatusExample.java

/**
  * Build command line options object./*w w  w. ja v  a2  s .  c o m*/
  */
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 Consumer Key.";
    OptionBuilder.withArgName("consumerKey");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription(consumerKeyMsg);
    Option consumerKey = OptionBuilder.create(CONSUMER_KEY_OPTION);
    opts.addOption(consumerKey);

    String consumerSecretMsg = "You API Consumer Secret.";
    OptionBuilder.withArgName("consumerSecret");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription(consumerSecretMsg);
    Option consumerSecret = OptionBuilder.create(CONSUMER_SECRET_OPTION);
    opts.addOption(consumerSecret);

    String accessTokenMsg = "You OAuth Access Token.";
    OptionBuilder.withArgName("accessToken");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription(accessTokenMsg);
    Option accessToken = OptionBuilder.create(ACCESS_TOKEN_OPTION);
    opts.addOption(accessToken);

    String tokenSecretMsg = "You OAuth Access Token Secret.";
    OptionBuilder.withArgName("accessTokenSecret");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription(tokenSecretMsg);
    Option accessTokenSecret = OptionBuilder.create(ACCESS_TOKEN_SECRET_OPTION);
    opts.addOption(accessTokenSecret);

    String statusMsg = "Text of the status.";
    OptionBuilder.withArgName("status");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription(statusMsg);
    Option status = OptionBuilder.create(STATUS_TEXT_OPTION);
    opts.addOption(status);

    String deleteMsg = "Delete current status.";
    Option delete = new Option(DELETE_OPTION, deleteMsg);
    opts.addOption(delete);

    return opts;
}

From source file:com.google.code.uclassify.client.examples.TrainExample.java

/**
 * Build command line options object.//from  www.jav  a  2s  .  c om
 * 
 * @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 Write Key.";
    OptionBuilder.withArgName("readKey");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription(consumerKeyMsg);
    Option consumerKey = OptionBuilder.create(WRITE_KEY);
    opts.addOption(consumerKey);

    String idMsg = "Classifier Name";
    OptionBuilder.withArgName("classifier");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription(idMsg);
    Option id = OptionBuilder.create(CLASSIFIER);
    opts.addOption(id);

    String urlMsg = "Text to be classified.";
    OptionBuilder.withArgName("text");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription(urlMsg);
    Option url = OptionBuilder.create(TEXT);
    opts.addOption(url);

    return opts;
}

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.  com*/
 * 
 * @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);
}