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.linkedinapi.client.examples.AsyncApiExample.java

/**
  * Build command line options object./*from  w w w  . j a v  a 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 user whose connections are to be fetched.";
    OptionBuilder.withArgName("id");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription(idMsg);
    Option id = OptionBuilder.create(ID_OPTION);
    opts.addOption(id);

    String emailMsg = "Email of the user whose connections are to be fetched.";
    OptionBuilder.withArgName("email");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription(emailMsg);
    Option email = OptionBuilder.create(EMAIL_OPTION);
    opts.addOption(email);

    String urlMsg = "Profile URL of the user whose connections are to be fetched.";
    OptionBuilder.withArgName("url");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription(urlMsg);
    Option url = OptionBuilder.create(URL_OPTION);
    opts.addOption(url);

    return opts;
}

From source file:com.googleapis.ajax.services.example.ResourceBundleGenerator.java

/**
 * Builds the options.//from  ww  w  .  ja  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 applicationKeyMsg = "You Application ID.";
    OptionBuilder.withArgName("appid");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription(applicationKeyMsg);
    Option applicationKey = OptionBuilder.create(APPLICATION_KEY_OPTION);
    opts.addOption(applicationKey);

    String resourceMsg = "Path to the default resource bundle (without .properties).";
    OptionBuilder.withArgName("resource");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription(resourceMsg);
    Option resource = OptionBuilder.create(RESOURCE_OPTION);
    opts.addOption(resource);

    String languagesMsg = "Comma separated list of languages. e.g. de,fr,es";
    OptionBuilder.withArgName("languages");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription(languagesMsg);
    Option languages = OptionBuilder.create(LANGUAGES_OPTION);
    opts.addOption(languages);

    return opts;
}

From source file:de.clusteval.data.randomizer.DataRandomizer.java

/**
 * Adds the default options of dataset generators to the given Options
 * attribute/*w  ww  .j  a va2s. c  o  m*/
 * 
 * @param options
 *            The existing Options attribute, holding already the options of
 *            the actual generator implementation.
 */
private void addDefaultOptions(final Options options) {
    OptionBuilder.withArgName("dataConfig");
    OptionBuilder.isRequired();
    OptionBuilder.hasArg();
    OptionBuilder.withDescription("The name of the data configuration to randomize");
    Option option = OptionBuilder.create("dataConfig");
    options.addOption(option);

}

From source file:com.archivas.clienttools.arcmover.cli.ArcProfileMgr.java

@SuppressWarnings({ "static-access" })
public Options getOptions() {
    if (cliOptions == null) {
        Options options = new Options();

        OptionGroup operations = new OptionGroup();

        // *** Adding a new option needs to be added to the cliOrder list
        operations.addOption(OptionBuilder.withDescription("Displays this help text (the default behavior).")
                .withLongOpt("help").create("h"));

        operations.addOption(OptionBuilder.hasOptionalArg().withArgName("profile_name").withDescription(
                "Lists information about the specified namespace profile.  If <profile_name> is omitted, lists information about all namespace profiles.")
                .withLongOpt("list").create("l"));
        operations.addOption(OptionBuilder.hasArg().withArgName("profile_name")
                .withDescription("Deletes the specified namespace profile.").withLongOpt("delete").create("d"));
        operations.addOption(OptionBuilder.hasArg().withArgName("profile_name")
                .withDescription("Creates a namespace profile with the specified name.").withLongOpt("create")
                .create("c"));

        options.addOptionGroup(operations);

        // List the valid profile types dynamically
        String profileTypesToString = "Type of namespace for which you are creating the namespace profile: ";
        for (ProfileType type : ProfileType.values()) {
            if (type != ProfileType.FILESYSTEM) { // Filesystem is already createdcd
                profileTypesToString += (type.toString() + " | ");
            }/* ww  w  .j  av a  2 s  .  c o m*/
        }
        profileTypesToString = profileTypesToString.substring(0, profileTypesToString.length() - 3);

        options.addOption(OptionBuilder.withArgName("profile_type").hasArg()
                .withDescription(profileTypesToString).withLongOpt("type").create());
        options.addOption(OptionBuilder.withArgName("tenant_name").hasArg().withDescription(
                "Name of the tenant that owns the namespace for which you are creating the namespace profile.")
                .withLongOpt("tenant").create());
        options.addOption(OptionBuilder.withArgName("namespace_name").hasArg()
                .withDescription("Name of the namespace for which you are creating the namespace profile.")
                .withLongOpt("namespace").create());
        options.addOption(OptionBuilder.withArgName("username").hasArg()
                .withDescription("Username of the data access account to use for namespace access.")
                .withLongOpt("username").create());
        options.addOption(OptionBuilder.withArgName("password").hasArg()
                .withDescription("Password of the data access account to use for namespace access.")
                .withLongOpt("password").create());
        options.addOption(OptionBuilder.withArgName("hostname").hasArg()
                .withDescription("The fully qualified domain name of the HCP system.").withLongOpt("hostname")
                .create());
        options.addOption(
                OptionBuilder.withDescription("Tells HCP-DM to use SSL when communicating with the HCP system.")
                        .withLongOpt("ssl").create());
        options.addOption(OptionBuilder.withDescription(
                "Tells HCP-DM to check whether custom metadata XML is well-formed prior to communicating with the HCP system.")
                .withLongOpt("check-cm").create());
        options.addOption(OptionBuilder
                .withDescription("Log into namespace anonymously.  Only valid with HCP 5.0 or later profile.")
                .withLongOpt("anon").create());
        options.addOption(OptionBuilder.withDescription(
                "Does not test if the namespace configuration provided can access HCP while creating the profile.")
                .withLongOpt("notest").create());
        options.addOption(OptionBuilder.withArgName("address1[,address2]...").hasArg().withDescription(
                "Comma-separated list of one or more IP addresses to use to connect to the HCP system.  If omitted, HCP-DM uses the hostname.")
                .withLongOpt("ips").create());
        if (ALLOW_PORT) {
            options.addOption(OptionBuilder.withArgName("port").hasArg()
                    .withDescription("Port to connect to HCP on").withLongOpt("port").create());
        }

        cliOptions = options;
    }
    return cliOptions;
}

From source file:com.github.errantlinguist.latticevisualiser.ArgParser.java

/**
 * Creates and adds a state size multiplier option to a given
 * {@link Options} object./*from w w  w  .j av a 2 s  . c  o m*/
 * 
 * @param options
 *            The <code>Options</code> object to add to.
 */
private static void addStateSizeMultiplierOption(final Options options) {
    OptionBuilder.withLongOpt(STATE_SIZE_MULTIPLIER_KEY_LONG);
    OptionBuilder.withDescription(STATE_SIZE_MULTIPLIER_DESCR);
    OptionBuilder.hasArg();
    OptionBuilder.withArgName(SIZE_ARG_NAME);
    OptionBuilder.withType(double.class);

    final Option stateSizeMultiplier = OptionBuilder.create(STATE_SIZE_MULTIPLIER_KEY);
    options.addOption(stateSizeMultiplier);
}

From source file:de.vandermeer.skb.commons.utils.CLIApache.java

@Override
public Com_Coin declareOptions(PropertyTable prop) {
    String optShort;//w  w  w.  ja va2 s  .c  o m
    String optLong;
    CC_Warning ret = null;

    for (String current : prop.keys()) {
        if (prop.hasPropertyValue(current, EAttributeKeys.CLI_PARAMETER_TYPE)) {
            Object o = Skb_ObjectUtils.CONVERT(prop.get(current, EAttributeKeys.CLI_PARAMETER_LONG),
                    Object.class, NONull.get, NONone.get);
            if (!(o instanceof Com_Coin)) {
                optLong = o.toString();
            } else {
                optLong = null;
            }
            OptionBuilder.withLongOpt(optLong);

            o = Skb_ObjectUtils.CONVERT(prop.get(current, EAttributeKeys.CLI_PARAMETER_DESCRIPTION_SHORT),
                    Object.class, NONull.get, NONone.get);
            OptionBuilder.withDescription(o.toString());

            o = Skb_ObjectUtils.CONVERT(prop.get(current, EAttributeKeys.CLI_PARAMETER_DESCRIPTION_ARGUMENTS),
                    Object.class, NONull.get, NONone.get);
            if (!(o instanceof Com_Coin) && o.toString().length() > 0) {
                OptionBuilder.hasArg();
                OptionBuilder.withArgName(o.toString());
            } else {
                OptionBuilder.hasArg(false);
            }

            switch (this.typeMap
                    .getPair4Source(prop.get(current, EAttributeKeys.CLI_PARAMETER_TYPE).toString())) {
            case JAVA_BOOLEAN:
                OptionBuilder.withType(Boolean.class);
                break;
            case JAVA_DOUBLE:
                OptionBuilder.withType(Double.class);
                break;
            case JAVA_INTEGER:
                OptionBuilder.withType(Integer.class);
                break;
            case JAVA_LONG:
                OptionBuilder.withType(Long.class);
                break;
            case JAVA_STRING:
            default:
                OptionBuilder.withType(String.class);
                break;
            }

            o = prop.get(current, EAttributeKeys.CLI_PARAMETER_SHORT);
            if (o != null && !(o instanceof Com_Coin)) {
                optShort = o.toString();
            } else {
                optShort = null;
            }

            if (optShort != null && optLong != null) {
                this.options.addOption(OptionBuilder.create(optShort.charAt(0)));
                this.optionList.put(current, optLong);
            } else if (optLong != null) {
                this.options.addOption(OptionBuilder.create());
                this.optionList.put(current, optLong);
            } else {
                //dummy create, nothing to be done since no option set (short/long)
                OptionBuilder.withLongOpt("__dummyLongOpt__");
                OptionBuilder.create();

                if (ret == null) {
                    ret = new CC_Warning();
                }
                ret.add(new Message5WH_Builder().addWhat("no short and no long options for <").addWhat(current)
                        .addWhat(">").build());
            }
        }
    }

    if (ret == null) {
        return NOSuccess.get;
    }
    return ret;
}

From source file:SearchApiExample.java

/**
  * Build command line options object./*from   w w  w .java 2s  .  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);

    OptionBuilder.withArgName("keywords");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription("keywords");
    opts.addOption(OptionBuilder.create(KEYWORDS_OPTION));

    OptionBuilder.withArgName("name");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription("name");
    opts.addOption(OptionBuilder.create(NAME_OPTION));

    OptionBuilder.withArgName("company");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription("company");
    opts.addOption(OptionBuilder.create(COMPANY_OPTION));

    OptionBuilder.withArgName("current-company");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription("current-company");
    opts.addOption(OptionBuilder.create(CURRENT_COMPANY_OPTION));

    OptionBuilder.withArgName("title");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription("title");
    opts.addOption(OptionBuilder.create(TITLE_OPTION));

    OptionBuilder.withArgName("current-title");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription("current-title");
    opts.addOption(OptionBuilder.create(CURRENT_TITLE_OPTION));

    OptionBuilder.withArgName("industry-code");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription("industry-code");
    opts.addOption(OptionBuilder.create(INDUSTRY_CODE_OPTION));

    OptionBuilder.withArgName("search-location-type");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription("search-location-type");
    opts.addOption(OptionBuilder.create(SEARCH_LOCATION_TYPE_OPTION));

    OptionBuilder.withArgName("country-code");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription("country-code");
    opts.addOption(OptionBuilder.create(COUNTRY_CODE_OPTION));

    OptionBuilder.withArgName("postal-code");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription("postal-code");
    opts.addOption(OptionBuilder.create(POSTAL_CODE_OPTION));

    OptionBuilder.withArgName("network");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription("network");
    opts.addOption(OptionBuilder.create(NETWORK_OPTION));

    return opts;
}

From source file:com.github.errantlinguist.latticevisualiser.ArgParser.java

/**
 * Creates and adds a horizontal size option to a given {@link Options}
 * object./*from ww  w  . jav  a  2  s  .  co m*/
 * 
 * @param options
 *            The <code>Options</code> object to add to.
 */
private static void addXSizeOption(final Options options) {
    OptionBuilder.withLongOpt(WIDTH_KEY_LONG);
    OptionBuilder.withDescription(WIDTH_DESCR);
    OptionBuilder.hasArg();
    OptionBuilder.withArgName(SIZE_ARG_NAME);
    OptionBuilder.withType(Integer.class);

    final Option width = OptionBuilder.create(WIDTH_KEY);
    options.addOption(width);
}

From source file:edu.wustl.mir.erl.ihe.xdsi.util.StoreSCU.java

@SuppressWarnings("static-access")
public static void addUIDSuffixOption(Options opts) {
    opts.addOption(OptionBuilder.hasArg().withArgName("suffix").withDescription(rb.getString("uid-suffix"))
            .withLongOpt("uid-suffix").create(null));
}

From source file:com.github.errantlinguist.latticevisualiser.ArgParser.java

/**
 * Creates and adds a vertical size option to a given {@link Options}
 * object.//ww  w.  ja v  a2s.c o m
 * 
 * @param options
 *            The <code>Options</code> object to add to.
 */
private static void addYSizeOption(final Options options) {
    OptionBuilder.withLongOpt(HEIGHT_KEY_LONG);
    OptionBuilder.withDescription(HEIGHT_DESCR);
    OptionBuilder.hasArg();
    OptionBuilder.withArgName(SIZE_ARG_NAME);
    OptionBuilder.withType(int.class);

    final Option height = OptionBuilder.create(HEIGHT_KEY);
    options.addOption(height);
}