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

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

Introduction

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

Prototype

public static OptionBuilder withValueSeparator() 

Source Link

Document

The next Option created uses '=' as a means to separate argument values.

Usage

From source file:org.apache.ambari.client.ClusterCreate.java

public void addOptions() {

    Option wait = new Option("wait", "Optionally wait for cluster to reach desired state");
    Option dry_run = new Option("dry_run", "Dry run");
    Option help = new Option("help", "Help");

    OptionBuilder.withArgName("cluster_name");
    OptionBuilder.isRequired();/*from   w w w.  j  a  v  a2s.  c  o m*/
    OptionBuilder.hasArg();
    OptionBuilder.withDescription("Name of the cluster to be created");
    Option name = OptionBuilder.create("name");

    OptionBuilder.withArgName("stack_name");
    OptionBuilder.isRequired();
    OptionBuilder.hasArg();
    OptionBuilder.withDescription("Name of the cluster stack");
    Option stack = OptionBuilder.create("stack");

    OptionBuilder.withArgName("\"node_exp1; node_exp2; ...\"");
    OptionBuilder.isRequired();
    OptionBuilder.hasArg();
    OptionBuilder.withDescription(
            "List of node range expressions separated by semicolon (;) and contained in double quotes (\"\")");
    Option nodes = OptionBuilder.create("nodes");

    OptionBuilder.withArgName("stack_revision");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription("Stack revision, if not specified latest revision is used");
    Option revision = OptionBuilder.create("revision");

    OptionBuilder.withArgName("description");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription("Description to be associated with cluster");
    Option desc = OptionBuilder.create("desc");

    OptionBuilder.withArgName("goalstate");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription("Desired goal state of the cluster");
    Option goalstate = OptionBuilder.create("goalstate");

    OptionBuilder.withArgName("\"component-1; component-2; ...\"");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription(
            "List of components to be active in the cluster. Components are seperated by semicolon \";\"");
    Option services = OptionBuilder.create("services");

    OptionBuilder.withArgName("rolename=\"node_exp1; node_exp2; ... \"");
    OptionBuilder.hasArgs(2);
    OptionBuilder.withValueSeparator();
    OptionBuilder.withDescription(
            "Provide node range expressions for a given rolename separated by semicolon (;) and contained in double quotes (\"\")");
    Option role = OptionBuilder.create("role");

    this.options = new Options();
    options.addOption(wait);
    options.addOption(dry_run);
    options.addOption(name);
    options.addOption(stack);
    options.addOption(revision);
    options.addOption(desc);
    options.addOption(role);
    options.addOption(goalstate);
    options.addOption(nodes);
    options.addOption(services);
    options.addOption(help);
}

From source file:org.apache.ambari.client.ClusterUpdate.java

public void addOptions() {

    Option wait = new Option("wait", "Optionally wait for cluster to reach desired state");
    Option dry_run = new Option("dry_run", "Dry run");
    Option help = new Option("help", "Help");

    OptionBuilder.withArgName("cluster_name");
    OptionBuilder.isRequired();//from w w w. ja v  a2s.co m
    OptionBuilder.hasArg();
    OptionBuilder.withDescription("Name of the cluster to be updated");
    Option name = OptionBuilder.create("name");

    OptionBuilder.withArgName("stack_name");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription("Name of the cluster stack");
    Option stack = OptionBuilder.create("stack");

    OptionBuilder.withArgName("\"node_exp1; node_exp2; ...\"");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription(
            "List of node range expressions separated by semicolon (;) and contained in double quotes (\"\")");
    Option nodes = OptionBuilder.create("nodes");

    OptionBuilder.withArgName("stack_revision");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription("Stack revision");
    Option revision = OptionBuilder.create("revision");

    OptionBuilder.withArgName("description");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription("Description associated with cluster");
    Option desc = OptionBuilder.create("desc");

    OptionBuilder.withArgName("goalstate");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription("Desired goal state of the cluster");
    Option goalstate = OptionBuilder.create("goalstate");

    OptionBuilder.withArgName("\"component-1; component-2; ...\"");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription(
            "List of components to be active in the cluster. Components are seperated by semicolon \";\"");
    Option services = OptionBuilder.create("services");

    OptionBuilder.withArgName("rolename=\"node_exp1; node_exp2; ... \"");
    OptionBuilder.hasArgs(2);
    OptionBuilder.withValueSeparator();
    OptionBuilder.withDescription(
            "Node range expressions for a given rolename separated by semicolon (;) and contained in double quotes (\"\")");
    Option role = OptionBuilder.create("role");

    this.options = new Options();
    options.addOption(wait);
    options.addOption(dry_run);
    options.addOption(name);
    options.addOption(stack);
    options.addOption(revision);
    options.addOption(desc);
    options.addOption(role);
    options.addOption(goalstate);
    options.addOption(nodes);
    options.addOption(services);
    options.addOption(help);
}

From source file:org.apache.hadoop.hive.cli.OptionsProcessor.java

@SuppressWarnings("static-access")
public OptionsProcessor() {

    // -database database
    options.addOption(OptionBuilder.hasArg().withArgName("databasename").withLongOpt("database")
            .withDescription("Specify the database to use").create());

    // -e 'quoted-query-string'
    options.addOption(OptionBuilder.hasArg().withArgName("quoted-query-string")
            .withDescription("SQL from command line").create('e'));

    // -f <query-file>
    options.addOption(/*from w  ww.j a  v  a  2  s  .co  m*/
            OptionBuilder.hasArg().withArgName("filename").withDescription("SQL from files").create('f'));

    // -i <init-query-file>
    options.addOption(OptionBuilder.hasArg().withArgName("filename").withDescription("Initialization SQL file")
            .create('i'));

    // -hiveconf x=y
    options.addOption(OptionBuilder.withValueSeparator().hasArgs(2).withArgName("property=value")
            .withLongOpt("hiveconf").withDescription("Use value for given property").create());

    // Substitution option -d, --define
    options.addOption(OptionBuilder.withValueSeparator().hasArgs(2).withArgName("key=value")
            .withLongOpt("define")
            .withDescription("Variable substitution to apply to Hive commands. e.g. -d A=B or --define A=B")
            .create('d'));

    // Substitution option --hivevar
    options.addOption(OptionBuilder.withValueSeparator().hasArgs(2).withArgName("key=value")
            .withLongOpt("hivevar")
            .withDescription("Variable substitution to apply to Hive commands. e.g. --hivevar A=B").create());

    // [-S|--silent]
    options.addOption(new Option("S", "silent", false, "Silent mode in interactive shell"));

    // [-v|--verbose]
    options.addOption(new Option("v", "verbose", false, "Verbose mode (echo executed SQL to the console)"));

    // [-H|--help]
    options.addOption(new Option("H", "help", false, "Print help information"));

}

From source file:org.apache.hadoop.hive.common.cli.CommonCliOptions.java

/**
 * Create an instance with common options (help, verbose, etc...).
 *
 * @param cliname the name of the command
 * @param includeHiveConf include "hiveconf" as an option if true
 *///  w  ww  .ja  v a2s. co m
@SuppressWarnings("static-access")
public CommonCliOptions(String cliname, boolean includeHiveConf) {
    this.cliname = cliname;

    // [-v|--verbose]
    OPTIONS.addOption(new Option("v", "verbose", false, "Verbose mode"));

    // [-h|--help]
    OPTIONS.addOption(new Option("h", "help", false, "Print help information"));

    if (includeHiveConf) {
        OPTIONS.addOption(OptionBuilder.withValueSeparator().hasArgs(2).withArgName("property=value")
                .withLongOpt("hiveconf").withDescription("Use value for given property").create());
    }
}

From source file:org.apache.hadoop.hive.llap.cli.LlapOptionsProcessor.java

@SuppressWarnings("static-access")
public LlapOptionsProcessor() {

    // set the number of instances on which llap should run
    options.addOption(OptionBuilder.hasArg().withArgName(OPTION_INSTANCES).withLongOpt(OPTION_INSTANCES)
            .withDescription("Specify the number of instances to run this on").create('i'));

    options.addOption(OptionBuilder.hasArg().withArgName(OPTION_NAME).withLongOpt(OPTION_NAME)
            .withDescription("Cluster name for YARN registry").create('n'));

    options.addOption(OptionBuilder.hasArg().withArgName(OPTION_DIRECTORY).withLongOpt(OPTION_DIRECTORY)
            .withDescription("Temp directory for jars etc.").create('d'));

    options.addOption(OptionBuilder.hasArg().withArgName(OPTION_ARGS).withLongOpt(OPTION_ARGS)
            .withDescription("java arguments to the llap instance").create('a'));

    options.addOption(OptionBuilder.hasArg().withArgName(OPTION_LOGLEVEL).withLongOpt(OPTION_LOGLEVEL)
            .withDescription("log levels for the llap instance").create('l'));

    options.addOption(OptionBuilder.hasArg().withArgName(OPTION_LOGGER).withLongOpt(OPTION_LOGGER)
            .withDescription("logger for llap instance ([" + LogHelpers.LLAP_LOGGER_NAME_RFA + "], "
                    + LogHelpers.LLAP_LOGGER_NAME_QUERY_ROUTING + ", " + LogHelpers.LLAP_LOGGER_NAME_CONSOLE)
            .create());/*w  w w.j a v  a 2s.  co m*/

    options.addOption(OptionBuilder.hasArg().withArgName(OPTION_CHAOS_MONKEY).withLongOpt(OPTION_CHAOS_MONKEY)
            .withDescription("chaosmonkey interval").create('m'));

    options.addOption(OptionBuilder.hasArg(false).withArgName(OPTION_SLIDER_DEFAULT_KEYTAB)
            .withLongOpt(OPTION_SLIDER_DEFAULT_KEYTAB)
            .withDescription("try to set default settings for Slider AM keytab; mostly for dev testing")
            .create());

    options.addOption(OptionBuilder.hasArg().withArgName(OPTION_SLIDER_KEYTAB_DIR)
            .withLongOpt(OPTION_SLIDER_KEYTAB_DIR)
            .withDescription(
                    "Slider AM keytab directory on HDFS (where the headless user keytab is stored by Slider keytab installation, e.g. .slider/keytabs/llap)")
            .create());

    options.addOption(OptionBuilder.hasArg().withArgName(OPTION_SLIDER_KEYTAB).withLongOpt(OPTION_SLIDER_KEYTAB)
            .withDescription("Slider AM keytab file name inside " + OPTION_SLIDER_KEYTAB_DIR).create());

    options.addOption(OptionBuilder.hasArg().withArgName(OPTION_SLIDER_PRINCIPAL)
            .withLongOpt(OPTION_SLIDER_PRINCIPAL)
            .withDescription(
                    "Slider AM principal; should be the user running the cluster, e.g. hive@EXAMPLE.COM")
            .create());

    options.addOption(OptionBuilder.hasArg().withArgName(OPTION_SLIDER_PLACEMENT)
            .withLongOpt(OPTION_SLIDER_PLACEMENT)
            .withDescription(
                    "Slider placement policy; see slider documentation at https://slider.incubator.apache.org/docs/placement.html."
                            + " 4 means anti-affinity (the default; unnecessary if LLAP is going to take more than half of the YARN capacity of a node), 0 is normal.")
            .create());

    options.addOption(OptionBuilder.hasArg().withArgName(OPTION_EXECUTORS).withLongOpt(OPTION_EXECUTORS)
            .withDescription("executor per instance").create('e'));

    options.addOption(OptionBuilder.hasArg().withArgName(OPTION_CACHE).withLongOpt(OPTION_CACHE)
            .withDescription("cache size per instance").create('c'));

    options.addOption(OptionBuilder.hasArg().withArgName(OPTION_SIZE).withLongOpt(OPTION_SIZE)
            .withDescription("container size per instance").create('s'));

    options.addOption(OptionBuilder.hasArg().withArgName(OPTION_XMX).withLongOpt(OPTION_XMX)
            .withDescription("working memory size").create('w'));

    options.addOption(OptionBuilder.hasArg().withArgName(OPTION_LLAP_QUEUE).withLongOpt(OPTION_LLAP_QUEUE)
            .withDescription("The queue within which LLAP will be started").create('q'));

    options.addOption(OptionBuilder.hasArg().withArgName(OPTION_OUTPUT_DIR).withLongOpt(OPTION_OUTPUT_DIR)
            .withDescription("Output directory for the generated scripts").create());

    options.addOption(OptionBuilder.hasArg().withArgName(OPTION_AUXJARS).withLongOpt(OPTION_AUXJARS)
            .withDescription(
                    "additional jars to package (by default, JSON SerDe jar is packaged" + " if available)")
            .create('j'));

    options.addOption(OptionBuilder.hasArg().withArgName(OPTION_AUXHBASE).withLongOpt(OPTION_AUXHBASE)
            .withDescription("whether to package the HBase jars (true by default)").create('h'));

    options.addOption(OptionBuilder.hasArg().withArgName(OPTION_AUXHIVE).withLongOpt(OPTION_AUXHIVE)
            .withDescription("whether to package the Hive aux jars (true by default)").create(OPTION_AUXHIVE));

    options.addOption(OptionBuilder.hasArg().withArgName(OPTION_JAVA_HOME).withLongOpt(OPTION_JAVA_HOME)
            .withDescription(
                    "Path to the JRE/JDK. This should be installed at the same location on all cluster nodes ($JAVA_HOME, java.home by default)")
            .create());

    // -hiveconf x=y
    options.addOption(OptionBuilder.withValueSeparator().hasArgs(2).withArgName("property=value")
            .withLongOpt(OPTION_HIVECONF)
            .withDescription("Use value for given property. Overridden by explicit parameters").create());

    options.addOption(OptionBuilder.hasArg().withArgName("b").withLongOpt(OPTION_SLIDER_AM_CONTAINER_MB)
            .withDescription("The size of the slider AppMaster container in MB").create('b'));

    options.addOption(OptionBuilder.withValueSeparator().hasArgs(2).withArgName("property=value")
            .withLongOpt(OPTION_SLIDER_APPCONFIG_GLOBAL)
            .withDescription("Property (key=value) to be set in the global section of the Slider appConfig")
            .create());

    options.addOption(OptionBuilder.hasArg().withArgName(OPTION_IO_THREADS).withLongOpt(OPTION_IO_THREADS)
            .withDescription("executor per instance").create('t'));

    options.addOption(OptionBuilder.hasArg(false).withArgName(OPTION_START).withLongOpt(OPTION_START)
            .withDescription("immediately start the cluster").create('z'));

    // [-H|--help]
    options.addOption(new Option("H", "help", false, "Print help information"));
}

From source file:org.apache.hadoop.hive.llap.LlapDump.java

static Options createOptions() {
    Options result = new Options();

    result.addOption(OptionBuilder.withLongOpt("location").withDescription("HS2 url").hasArg().create('l'));

    result.addOption(OptionBuilder.withLongOpt("user").withDescription("user name").hasArg().create('u'));

    result.addOption(OptionBuilder.withLongOpt("pwd").withDescription("password").hasArg().create('p'));

    result.addOption(OptionBuilder.withLongOpt("num").withDescription("number of splits").hasArg().create('n'));

    result.addOption(OptionBuilder.withValueSeparator().hasArgs(2).withArgName("property=value")
            .withLongOpt("hiveconf").withDescription("Use value for given property").create());

    result.addOption(OptionBuilder.withLongOpt("help").withDescription("help").hasArg(false).create('h'));

    return result;
}

From source file:org.apache.hadoop.hive.ql.util.HiveStrictManagedMigration.java

static Options createOptions() {
    Options result = new Options();

    // -hiveconf x=y
    result.addOption(OptionBuilder.withValueSeparator().hasArgs(2).withArgName("property=value")
            .withLongOpt("hiveconf").withDescription("Use value for given property").create());

    result.addOption(OptionBuilder.withLongOpt("dryRun")
            .withDescription("Show what migration actions would be taken without actually running commands")
            .create());//from ww w .  j ava  2  s  .  c  om

    result.addOption(OptionBuilder.withLongOpt("dbRegex")
            .withDescription("Regular expression to match database names on which this tool will be run")
            .hasArg().create('d'));

    result.addOption(OptionBuilder.withLongOpt("tableRegex")
            .withDescription("Regular expression to match table names on which this tool will be run").hasArg()
            .create('t'));

    result.addOption(OptionBuilder.withLongOpt("oldWarehouseRoot")
            .withDescription("Location of the previous warehouse root").hasArg().create());

    result.addOption(OptionBuilder.withLongOpt("migrationOption")
            .withDescription("Table migration option (automatic|external|managed|validate|none)").hasArg()
            .create('m'));

    result.addOption(OptionBuilder.withLongOpt("shouldModifyManagedTableLocation").withDescription(
            "Whether managed tables should have their data moved from the old warehouse path to the current warehouse path")
            .create());

    result.addOption(OptionBuilder.withLongOpt("shouldModifyManagedTableOwner")
            .withDescription(
                    "Whether managed tables should have their directory owners changed to the hive user")
            .create());

    result.addOption(OptionBuilder.withLongOpt("shouldModifyManagedTablePermissions").withDescription(
            "Whether managed tables should have their directory permissions changed to conform to strict managed tables mode")
            .create());

    result.addOption(OptionBuilder.withLongOpt("modifyManagedTables").withDescription(
            "This setting enables the shouldModifyManagedTableLocation, shouldModifyManagedTableOwner, shouldModifyManagedTablePermissions options")
            .create());

    result.addOption(OptionBuilder.withLongOpt("help").withDescription("print help message").create('h'));

    return result;
}

From source file:org.apache.hive.beeline.cli.CliOptionsProcessor.java

public CliOptionsProcessor() {
    // -database database
    options.addOption(OptionBuilder.hasArg().withArgName("databasename").withLongOpt("database")
            .withDescription("Specify the database to use").create());

    // -e 'quoted-query-string'
    options.addOption(OptionBuilder.hasArg().withArgName("quoted-query-string")
            .withDescription("SQL from command line").create('e'));

    // -f <query-file>
    options.addOption(//from  w ww .j a v  a  2  s.c om
            OptionBuilder.hasArg().withArgName("filename").withDescription("SQL from " + "files").create('f'));

    // -i <init-query-file>
    options.addOption(OptionBuilder.hasArg().withArgName("filename").withDescription("Initialization SQL file")
            .create('i'));

    // -hiveconf x=y
    options.addOption(OptionBuilder.withValueSeparator().hasArgs(2).withArgName("property=value")
            .withLongOpt("hiveconf").withDescription("Use value for given property").create());

    // Substitution option -d, --define
    options.addOption(
            OptionBuilder.withValueSeparator().hasArgs(2).withArgName("key=value").withLongOpt("define")
                    .withDescription(
                            "Variable substitution to apply to Hive commands. e" + ".g. -d A=B or --define A=B")
                    .create('d'));

    // Substitution option --hivevar
    options.addOption(
            OptionBuilder.withValueSeparator().hasArgs(2).withArgName("key=value").withLongOpt("hivevar")
                    .withDescription("Variable substitution to apply to Hive commands. " + "e.g. --hivevar A=B")
                    .create());

    // [-S|--silent]
    options.addOption(new Option("S", "silent", false, "Silent mode in interactive shell"));

    // [-v|--verbose]
    options.addOption(
            new Option("v", "verbose", false, "Verbose mode (echo executed SQL to the " + "console)"));

    // [-H|--help]
    options.addOption(new Option("H", "help", false, "Print help information"));
}

From source file:org.apache.hive.hplsql.Arguments.java

@SuppressWarnings("static-access")
Arguments() {//  ww  w.  j ava2 s  . c  o  m
    // -e 'query'
    options.addOption(OptionBuilder.hasArg().withArgName("quoted-query-string")
            .withDescription("HPL/SQL from command line").create('e'));

    // -f <file>
    options.addOption(
            OptionBuilder.hasArg().withArgName("filename").withDescription("HPL/SQL from a file").create('f'));

    // -main entry_point_name
    options.addOption(OptionBuilder.hasArg().withArgName("procname")
            .withDescription("Entry point (procedure or function name)").create("main"));

    // -hiveconf x=y
    options.addOption(OptionBuilder.withValueSeparator().hasArgs(2).withArgName("property=value")
            .withLongOpt("hiveconf").withDescription("Value for given property").create());

    // Substitution option -d, --define
    options.addOption(
            OptionBuilder.withValueSeparator().hasArgs(2).withArgName("key=value").withLongOpt("define")
                    .withDescription("Variable substitution e.g. -d A=B or --define A=B").create('d'));

    // Substitution option --hivevar
    options.addOption(OptionBuilder.withValueSeparator().hasArgs(2).withArgName("key=value")
            .withLongOpt("hivevar").withDescription("Variable substitution e.g. --hivevar A=B").create());

    // [-version|--version]
    options.addOption(new Option("version", "version", false, "Print HPL/SQL version"));

    // [-trace|--trace]
    options.addOption(new Option("trace", "trace", false, "Print debug information"));

    // [-offline|--offline]
    options.addOption(new Option("offline", "offline", false, "Offline mode - skip SQL execution"));

    // [-H|--help]
    options.addOption(new Option("H", "help", false, "Print help information"));
}

From source file:org.apache.hive.jdbc.beeline.OptionsProcessor.java

@SuppressWarnings("static-access")
public OptionsProcessor() {

    // -database database
    options.addOption(OptionBuilder.hasArg().withArgName("databasename").withLongOpt("database")
            .withDescription("Specify the database to use").create());

    // -e 'quoted-query-string'
    options.addOption(OptionBuilder.hasArg().withArgName("quoted-query-string")
            .withDescription("SQL from command line").create('e'));

    // -f <query-file>
    options.addOption(/*  w w w.ja v a 2 s .  c  o m*/
            OptionBuilder.hasArg().withArgName("filename").withDescription("SQL from files").create('f'));

    // -hiveconf x=y
    options.addOption(OptionBuilder.withValueSeparator().hasArgs(2).withArgName("property=value")
            .withLongOpt("hiveconf").withDescription("Use value for given property").create());

    // -sessVar x=y
    options.addOption(OptionBuilder.withValueSeparator().hasArgs(2).withArgName("property=value")
            .withLongOpt("sessVar").withDescription("Use value for given property").create());

    // -h hostname/ippaddress
    options.addOption(OptionBuilder.hasArg().withArgName("hostname")
            .withDescription("connecting to Hive Server on remote host").create('h'));

    // -p port
    options.addOption(OptionBuilder.hasArg().withArgName("port")
            .withDescription("connecting to Hive Server on port number").create('p'));

    // Substitution option -d, --define
    options.addOption(OptionBuilder.withValueSeparator().hasArgs(2).withArgName("key=value")
            .withLongOpt("define")
            .withDescription("Variable subsitution to apply to hive commands. e.g. -d A=B or --define A=B")
            .create('d'));

    // Substitution option --hivevar
    options.addOption(OptionBuilder.withValueSeparator().hasArgs(2).withArgName("key=value")
            .withLongOpt("hivevar")
            .withDescription("Variable subsitution to apply to hive commands. e.g. --hivevar A=B").create());

    // [-S|--silent]
    options.addOption(new Option("S", "silent", false, "Silent mode in interactive shell"));

    // [-v|--verbose]
    options.addOption(new Option("v", "verbose", false, "Verbose mode (echo executed SQL to the console)"));

    // [-H|--help]
    options.addOption(new Option("H", "help", false, "Print help information"));
}