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

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

Introduction

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

Prototype

public static OptionBuilder withDescription(String newDescription) 

Source Link

Document

The next Option created will have the specified description

Usage

From source file:org.apache.geronimo.cli.daemon.DaemonCLParser.java

protected void addOverride() {
    OptionBuilder optionBuilder = OptionBuilder.hasArgs().withArgName("moduleId ...");
    optionBuilder = optionBuilder.withLongOpt(ARGUMENT_MODULE_OVERRIDE);
    optionBuilder = optionBuilder.withDescription("USE WITH CAUTION!  Overrides the modules in "
            + "var/config/config.xml such that only the modules listed on "
            + "the command line will be started.  Note that many J2EE "
            + "features depend on certain modules being started, so you "
            + "should be very careful what you omit.  Any arguments after "
            + "this are assumed to be module names.");
    Option option = optionBuilder.create(ARGUMENT_MODULE_OVERRIDE_SHORTFORM);
    options.addOption(option);/* ww w  . j av  a 2  s.  c o m*/
}

From source file:org.apache.geronimo.cli.deployer.DistributeCommandArgsImpl.java

protected void addTargets() {
    OptionBuilder optionBuilder = OptionBuilder.hasArg().withArgName("targets");
    optionBuilder = optionBuilder.withLongOpt(ARGUMENT_TARGETS);
    optionBuilder = optionBuilder
            .withDescription("If no targets are provided, the module is distributed to all available "
                    + "targets. Geronimo only provides one target (ever), so this is primarily "
                    + "useful when using a different driver.\n");
    Option option = optionBuilder.create(ARGUMENT_TARGETS_SHORTFORM);
    options.addOption(option);/*  w ww . ja va2 s  .  c  om*/
}

From source file:org.apache.geronimo.cli.deployer.InstallBundleCommandArgsImpl.java

protected void addStartLevel() {
    OptionBuilder optionBuilder = OptionBuilder.hasArg().withArgName("startLevel");
    optionBuilder = optionBuilder.withLongOpt(ARGUMENT_START_LEVEL);
    optionBuilder = optionBuilder.withDescription(
            "If no start level are provided, will use the framework's initial bundle start level");
    Option option = optionBuilder.create(ARGUMENT_START_LEVEL_SHORTFORM);
    options.addOption(option);/*from w  w w  . j  a v a2s . c o m*/
}

From source file:org.apache.geronimo.cli.deployer.InstallBundleCommandArgsImpl.java

protected void addGroupId() {
    OptionBuilder optionBuilder = OptionBuilder.hasArg().withArgName("groupId");
    optionBuilder = optionBuilder.withLongOpt(ARGUMENT_GROUP_ID);
    optionBuilder = optionBuilder
            .withDescription("If gourpId is not provided, will use \"default\" as its group id.");
    Option option = optionBuilder.create(ARGUMENT_GROUP_ID_SHORTFORM);
    options.addOption(option);/*w ww .j  a  v a 2s. co m*/
}

From source file:org.apache.geronimo.cli.deployer.InstallLibraryCommandArgsImpl.java

protected void addGroupId() {
    OptionBuilder optionBuilder = OptionBuilder.hasArg().withArgName(ARGUMENT_GROUP_ID);
    optionBuilder = optionBuilder.withLongOpt(ARGUMENT_GROUP_ID);
    optionBuilder = optionBuilder
            .withDescription("If a groupId is provided, the library file will be installed under that groupId. "
                    + "Otherwise, default will be used.");
    Option option = optionBuilder.create(ARGUMENT_GROUP_ID_SHORTFORM);
    options.addOption(option);/*from   w w  w.j a  va2s. c om*/
}

From source file:org.apache.hadoop.hdfs.tools.JMXGet.java

/**
 * parse args/*w w  w.  j a  v  a2s. c o m*/
 */
private static CommandLine parseArgs(Options opts, String... args) throws IllegalArgumentException {

    OptionBuilder.withArgName("NameNode|DataNode");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription("specify jmx service (NameNode by default)");
    Option jmx_service = OptionBuilder.create("service");

    OptionBuilder.withArgName("mbean server");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription("specify mbean server (localhost by default)");
    Option jmx_server = OptionBuilder.create("server");

    OptionBuilder.withDescription("print help");
    Option jmx_help = OptionBuilder.create("help");

    OptionBuilder.withArgName("mbean server port");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription("specify mbean server port, "
            + "if missing - it will try to connect to MBean Server in the same VM");
    Option jmx_port = OptionBuilder.create("port");

    OptionBuilder.withArgName("VM's connector url");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription("connect to the VM on the same machine;"
            + "\n use:\n jstat -J-Djstat.showUnsupported=true -snap <vmpid> | "
            + "grep sun.management.JMXConnectorServer.address\n " + "to find the url");
    Option jmx_localVM = OptionBuilder.create("localVM");

    opts.addOption(jmx_server);
    opts.addOption(jmx_help);
    opts.addOption(jmx_service);
    opts.addOption(jmx_port);
    opts.addOption(jmx_localVM);

    CommandLine commandLine = null;
    CommandLineParser parser = new GnuParser();
    try {
        commandLine = parser.parse(opts, args, true);
    } catch (ParseException e) {
        printUsage(opts);
        throw new IllegalArgumentException("invalid args: " + e.getMessage());
    }
    return commandLine;
}

From source file:org.apache.hadoop.hive.metastore.tools.SchemaToolCommandLine.java

@SuppressWarnings("static-access")
private Options createOptions(OptionGroup additionalOptions) {
    Option help = new Option("help", "print this message");
    Option infoOpt = new Option("info", "Show config and schema details");
    Option upgradeOpt = new Option("upgradeSchema", "Schema upgrade");
    Option upgradeFromOpt = OptionBuilder.withArgName("upgradeFrom").hasArg()
            .withDescription("Schema upgrade from a version").create("upgradeSchemaFrom");
    Option initOpt = new Option("initSchema", "Schema initialization");
    Option initToOpt = OptionBuilder.withArgName("initTo").hasArg()
            .withDescription("Schema initialization to a version").create("initSchemaTo");
    Option initOrUpgradeSchemaOpt = new Option("initOrUpgradeSchema",
            "Initialize or upgrade schema to latest version");
    Option validateOpt = new Option("validate", "Validate the database");
    Option createCatalog = OptionBuilder.hasArg()
            .withDescription("Create a catalog, requires --catalogLocation parameter as well")
            .create("createCatalog");
    Option alterCatalog = OptionBuilder.hasArg()
            .withDescription(/*w  ww  .j  a  v  a 2  s  . c om*/
                    "Alter a catalog, requires --catalogLocation and/or --catalogDescription parameter as well")
            .create("alterCatalog");
    Option moveDatabase = OptionBuilder.hasArg()
            .withDescription("Move a database between catalogs.  Argument is the database name. "
                    + "Requires --fromCatalog and --toCatalog parameters as well")
            .create("moveDatabase");
    Option moveTable = OptionBuilder.hasArg()
            .withDescription("Move a table to a different database.  Argument is the table name. "
                    + "Requires --fromCatalog, --toCatalog, --fromDatabase, and --toDatabase "
                    + " parameters as well.")
            .create("moveTable");
    Option createUserOpt = new Option("createUser", "Create the Hive user, set hiveUser to the db"
            + " admin user and the hive password to the db admin password with this");

    OptionGroup optGroup = new OptionGroup();
    optGroup.addOption(help).addOption(infoOpt).addOption(upgradeOpt).addOption(upgradeFromOpt)
            .addOption(initOpt).addOption(initToOpt).addOption(initOrUpgradeSchemaOpt).addOption(validateOpt)
            .addOption(createCatalog).addOption(alterCatalog).addOption(moveDatabase).addOption(moveTable)
            .addOption(createUserOpt);
    optGroup.setRequired(true);

    Option userNameOpt = OptionBuilder.withArgName("user").hasArgs()
            .withDescription("Override config file user name").create("userName");
    Option passwdOpt = OptionBuilder.withArgName("password").hasArgs()
            .withDescription("Override config file password").create("passWord");
    Option dbTypeOpt = OptionBuilder.withArgName("databaseType").hasArgs()
            .withDescription("Metastore database type").isRequired().create("dbType");
    Option hiveUserOpt = OptionBuilder.hasArg().withDescription("Hive user (for use with createUser)")
            .create("hiveUser");
    Option hivePasswdOpt = OptionBuilder.hasArg().withDescription("Hive password (for use with createUser)")
            .create("hivePassword");
    Option hiveDbOpt = OptionBuilder.hasArg().withDescription("Hive database (for use with createUser)")
            .create("hiveDb");
    /*
    Option metaDbTypeOpt = OptionBuilder.withArgName("metaDatabaseType")
        .hasArgs().withDescription("Used only if upgrading the system catalog for hive")
        .create("metaDbType");
        */
    Option urlOpt = OptionBuilder.withArgName("url").hasArgs().withDescription("connection url to the database")
            .create("url");
    Option driverOpt = OptionBuilder.withArgName("driver").hasArgs()
            .withDescription("driver name for connection").create("driver");
    Option dbOpts = OptionBuilder.withArgName("databaseOpts").hasArgs()
            .withDescription("Backend DB specific options").create("dbOpts");
    Option dryRunOpt = new Option("dryRun", "list SQL scripts (no execute)");
    Option verboseOpt = new Option("verbose", "only print SQL statements");
    Option serversOpt = OptionBuilder.withArgName("serverList").hasArgs()
            .withDescription("a comma-separated list of servers used in location validation in the format of "
                    + "scheme://authority (e.g. hdfs://localhost:8000)")
            .create("servers");
    Option catalogLocation = OptionBuilder.hasArg()
            .withDescription("Location of new catalog, required when adding a catalog")
            .create("catalogLocation");
    Option catalogDescription = OptionBuilder.hasArg().withDescription("Description of new catalog")
            .create("catalogDescription");
    Option ifNotExists = OptionBuilder
            .withDescription("If passed then it is not an error to create an existing catalog")
            .create("ifNotExists");
    Option fromCatalog = OptionBuilder.hasArg()
            .withDescription("Catalog a moving database or table is coming from.  This is "
                    + "required if you are moving a database or table.")
            .create("fromCatalog");
    Option toCatalog = OptionBuilder.hasArg()
            .withDescription("Catalog a moving database or table is going to.  This is "
                    + "required if you are moving a database or table.")
            .create("toCatalog");
    Option fromDatabase = OptionBuilder.hasArg()
            .withDescription(
                    "Database a moving table is coming from.  This is " + "required if you are moving a table.")
            .create("fromDatabase");
    Option toDatabase = OptionBuilder.hasArg()
            .withDescription(
                    "Database a moving table is going to.  This is " + "required if you are moving a table.")
            .create("toDatabase");

    Options options = new Options();
    options.addOption(help);
    options.addOptionGroup(optGroup);
    options.addOption(dbTypeOpt);
    //options.addOption(metaDbTypeOpt);
    options.addOption(userNameOpt);
    options.addOption(passwdOpt);
    options.addOption(urlOpt);
    options.addOption(driverOpt);
    options.addOption(dbOpts);
    options.addOption(dryRunOpt);
    options.addOption(verboseOpt);
    options.addOption(serversOpt);
    options.addOption(catalogLocation);
    options.addOption(catalogDescription);
    options.addOption(ifNotExists);
    options.addOption(fromCatalog);
    options.addOption(toCatalog);
    options.addOption(fromDatabase);
    options.addOption(toDatabase);
    options.addOption(hiveUserOpt);
    options.addOption(hivePasswdOpt);
    options.addOption(hiveDbOpt);
    if (additionalOptions != null)
        options.addOptionGroup(additionalOptions);

    return options;
}

From source file:org.apache.hadoop.mapreduce.MiniHadoopClusterManager.java

/**
 * Creates configuration options object.
 *///from   w  ww.  j av  a2s.  co  m
@SuppressWarnings("static-access")
private Options makeOptions() {
    Options options = new Options();
    options.addOption("nodfs", false, "Don't start a mini DFS cluster")
            .addOption("nomr", false, "Don't start a mini MR cluster")
            .addOption("nodemanagers", true, "How many nodemanagers to start (default 1)")
            .addOption("datanodes", true, "How many datanodes to start (default 1)")
            .addOption("format", false, "Format the DFS (default false)")
            .addOption("nnport", true, "NameNode port (default 0--we choose)")
            .addOption("namenode", true,
                    "URL of the namenode (default " + "is either the DFS cluster or a temporary dir)")
            .addOption("rmport", true, "ResourceManager port (default 0--we choose)")
            .addOption("jhsport", true, "JobHistoryServer port (default 0--we choose)")
            .addOption(OptionBuilder.hasArgs().withArgName("property=value")
                    .withDescription("Options to pass into configuration object").create("D"))
            .addOption(OptionBuilder.hasArg().withArgName("path")
                    .withDescription("Save configuration to this XML file.").create("writeConfig"))
            .addOption(OptionBuilder.hasArg().withArgName("path")
                    .withDescription("Write basic information to this JSON file.").create("writeDetails"))
            .addOption(OptionBuilder.withDescription("Prints option help.").create("help"));
    return options;
}

From source file:org.apache.hadoop.test.MiniHadoopClusterManager.java

/**
 * Creates configuration options object.
 *//*from   w ww  .  j  ava 2s .  c om*/
@SuppressWarnings("static-access")
private Options makeOptions() {
    Options options = new Options();
    options.addOption("nodfs", false, "Don't start a mini DFS cluster")
            .addOption("nomr", false, "Don't start a mini MR cluster")
            .addOption("tasktrackers", true, "How many tasktrackers to start (default 1)")
            .addOption("datanodes", true, "How many datanodes to start (default 1)")
            .addOption("format", false, "Format the DFS (default false)")
            .addOption("nnport", true, "NameNode port (default 0--we choose)")
            .addOption("namenode", true,
                    "URL of the namenode (default " + "is either the DFS cluster or a temporary dir)")
            .addOption("jtport", true, "JobTracker port (default 0--we choose)")
            .addOption(OptionBuilder.hasArgs().withArgName("property=value")
                    .withDescription("Options to pass into configuration object").create("D"))
            .addOption(OptionBuilder.hasArg().withArgName("path")
                    .withDescription("Save configuration to this XML file.").create("writeConfig"))
            .addOption(OptionBuilder.hasArg().withArgName("path")
                    .withDescription("Write basic information to this JSON file.").create("writeDetails"))
            .addOption(OptionBuilder.withDescription("Prints option help.").create("help"));
    return options;
}

From source file:org.apache.james.jspf.impl.SPFQuery.java

/**
 * Return the generated Options//ww w .j a  v  a  2 s  .  c  om
 * 
 * @return options
 */
private static Options generateOptions() {
    Options options = new Options();

    OptionBuilder.withLongOpt(CMD_IP);
    OptionBuilder.withValueSeparator('=');
    OptionBuilder.withArgName("ip");
    OptionBuilder.withDescription("Sender IP address");
    OptionBuilder.isRequired();
    OptionBuilder.hasArg();
    options.addOption(OptionBuilder.create(CHAR_IP));

    OptionBuilder.withLongOpt(CMD_SENDER);
    OptionBuilder.withValueSeparator('=');
    OptionBuilder.withArgName("sender");
    OptionBuilder.withDescription("Sender address");
    OptionBuilder.isRequired();
    OptionBuilder.hasArg();
    options.addOption(OptionBuilder.create(CHAR_SENDER));

    OptionBuilder.withLongOpt(CMD_HELO);
    OptionBuilder.withValueSeparator('=');
    OptionBuilder.withArgName("helo");
    OptionBuilder.withDescription("Helo name");
    OptionBuilder.isRequired();
    OptionBuilder.hasArg();
    options.addOption(OptionBuilder.create(CHAR_HELO));

    OptionBuilder.withLongOpt(CMD_DEFAULT_EXP);
    OptionBuilder.withValueSeparator('=');
    OptionBuilder.withArgName("expl");
    OptionBuilder.withDescription("Default explanation");
    OptionBuilder.hasArg();
    options.addOption(OptionBuilder.create(CHAR_DEFAULT_EXP));

    OptionBuilder.withLongOpt(CMD_BEST_GUESS);
    OptionBuilder.withArgName("bestguess");
    OptionBuilder.withDescription("Enable 'best guess' rule");
    options.addOption(OptionBuilder.create(CHAR_BEST_GUESS));

    OptionBuilder.withLongOpt(CMD_TRUSTED_FORWARDER);
    OptionBuilder.withArgName("trustedfwd");
    OptionBuilder.withDescription("Enable 'trusted forwarder' rule");
    options.addOption(OptionBuilder.create(CHAR_TRUSTED_FORWARDER));

    OptionBuilder.withLongOpt(CMD_DEBUG);
    OptionBuilder.withArgName("debug");
    OptionBuilder.withDescription("Enable debug");
    options.addOption(OptionBuilder.create(CHAR_DEBUG));

    OptionBuilder.withLongOpt(CMD_VERBOSE);
    OptionBuilder.withArgName("verbose");
    OptionBuilder.withDescription("Enable verbose mode");
    options.addOption(OptionBuilder.create(CHAR_VERBOSE));

    return options;
}