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:org.apache.sqoop.shell.ShowLinkFunction.java

@SuppressWarnings("static-access")
public ShowLinkFunction() {
    this.addOption(OptionBuilder.withDescription(resourceString(Constants.RES_SHOW_PROMPT_DISPLAY_ALL_LINKS))
            .withLongOpt(Constants.OPT_ALL).create(Constants.OPT_ALL_CHAR));
    this.addOption(OptionBuilder.hasArg().withArgName(Constants.OPT_FROM)
            .withDescription(resourceString(Constants.RES_SHOW_PROMPT_DISPLAY_LINK_LID))
            .withLongOpt(Constants.OPT_FROM).create(Constants.OPT_LID_CHAR));
}

From source file:org.apache.sqoop.shell.ShowOptionFunction.java

/**
 * Construct new object./*ww w . j  a va 2s .  c  o  m*/
 */
@SuppressWarnings("static-access")
public ShowOptionFunction() {
    this.addOption(OptionBuilder.hasArg().withArgName(Constants.OPT_NAME)
            .withDescription(resource.getString(Constants.RES_SET_PROMPT_OPT_NAME))
            .withLongOpt(Constants.OPT_NAME).create(Constants.OPT_NAME_CHAR));
}

From source file:org.apache.sqoop.shell.ShowSubmissionFunction.java

@SuppressWarnings("static-access")
public ShowSubmissionFunction() {
    this.addOption(
            OptionBuilder.withDescription(resourceString(Constants.RES_SHOW_PROMPT_DISPLAY_ALL_SUBMISSIONS))
                    .withLongOpt(Constants.OPT_DETAIL).create(Constants.OPT_DETAIL_CHAR));
    this.addOption(OptionBuilder.hasArg().withArgName(Constants.OPT_JID)
            .withDescription(resourceString(Constants.RES_SHOW_PROMPT_DISPLAY_ALL_SUBMISSIONS_JOB_ID))
            .withLongOpt(Constants.OPT_JID).create(Constants.OPT_JID_CHAR));
}

From source file:org.apache.sqoop.shell.StartJobFunction.java

@SuppressWarnings("static-access")
public StartJobFunction() {
    this.addOption(OptionBuilder.hasArg().withArgName(Constants.OPT_JID)
            .withDescription(resourceString(Constants.RES_PROMPT_JOB_ID)).withLongOpt(Constants.OPT_JID)
            .create(Constants.OPT_JID_CHAR));
    this.addOption(OptionBuilder.withDescription(resourceString(Constants.RES_PROMPT_SYNCHRONOUS))
            .withLongOpt(Constants.OPT_SYNCHRONOUS).create(Constants.OPT_SYNCHRONOUS_CHAR));
}

From source file:org.apache.sqoop.shell.StopJobFunction.java

@SuppressWarnings("static-access")
public StopJobFunction() {
    this.addOption(OptionBuilder.hasArg().withArgName(Constants.OPT_JID)
            .withDescription(resourceString(Constants.RES_PROMPT_JOB_ID)).withLongOpt(Constants.OPT_JID)
            .create(Constants.OPT_JID_CHAR));
}

From source file:org.apache.sqoop.tool.BaseSqoopTool.java

/**
 * @param explicitHiveImport true if the user has an explicit --hive-import
 * available, or false if this is implied by the tool.
 * @return options governing interaction with Hive
 *//*  w ww.j  a v a  2  s. c o m*/
protected RelatedOptions getHiveOptions(boolean explicitHiveImport) {
    RelatedOptions hiveOpts = new RelatedOptions("Hive arguments");
    if (explicitHiveImport) {
        hiveOpts.addOption(OptionBuilder
                .withDescription(
                        "Import tables into Hive " + "(Uses Hive's default delimiters if none are set.)")
                .withLongOpt(HIVE_IMPORT_ARG).create());
    }

    hiveOpts.addOption(OptionBuilder.withArgName("dir").hasArg().withDescription("Override $HIVE_HOME")
            .withLongOpt(HIVE_HOME_ARG).create());
    hiveOpts.addOption(OptionBuilder.withDescription("Overwrite existing data in the Hive table")
            .withLongOpt(HIVE_OVERWRITE_ARG).create());
    hiveOpts.addOption(OptionBuilder.withDescription("Fail if the target hive table exists")
            .withLongOpt(CREATE_HIVE_TABLE_ARG).create());
    hiveOpts.addOption(OptionBuilder.withArgName("table-name").hasArg()
            .withDescription("Sets the table name to use when importing to hive").withLongOpt(HIVE_TABLE_ARG)
            .create());
    hiveOpts.addOption(OptionBuilder
            .withDescription(
                    "Drop Hive record \\0x01 and row delimiters " + "(\\n\\r) from imported string fields")
            .withLongOpt(HIVE_DROP_DELIMS_ARG).create());
    hiveOpts.addOption(OptionBuilder.hasArg()
            .withDescription("Replace Hive record \\0x01 and row delimiters "
                    + "(\\n\\r) from imported string fields with user-defined string")
            .withLongOpt(HIVE_DELIMS_REPLACEMENT_ARG).create());
    hiveOpts.addOption(OptionBuilder.withArgName("partition-key").hasArg()
            .withDescription("Sets the partition key to use when importing to hive")
            .withLongOpt(HIVE_PARTITION_KEY_ARG).create());
    hiveOpts.addOption(OptionBuilder.withArgName("partition-value").hasArg()
            .withDescription("Sets the partition value to use when importing " + "to hive")
            .withLongOpt(HIVE_PARTITION_VALUE_ARG).create());
    hiveOpts.addOption(
            OptionBuilder.hasArg().withDescription("Override mapping for specific column to hive" + " types.")
                    .withLongOpt(MAP_COLUMN_HIVE).create());

    return hiveOpts;
}

From source file:org.apache.sqoop.tool.BaseSqoopTool.java

/**
 * @param multiTable true if these options will be used for bulk code-gen.
 * @return options related to code generation.
 *//*from  w w  w .j  a va2 s.c o  m*/
protected RelatedOptions getCodeGenOpts(boolean multiTable) {
    RelatedOptions codeGenOpts = new RelatedOptions("Code generation arguments");
    codeGenOpts.addOption(OptionBuilder.withArgName("dir").hasArg()
            .withDescription("Output directory for generated code").withLongOpt(CODE_OUT_DIR_ARG).create());
    codeGenOpts.addOption(OptionBuilder.withArgName("dir").hasArg()
            .withDescription("Output directory for compiled objects").withLongOpt(BIN_OUT_DIR_ARG).create());
    codeGenOpts.addOption(OptionBuilder.withArgName("name").hasArg()
            .withDescription("Put auto-generated classes in this package").withLongOpt(PACKAGE_NAME_ARG)
            .create());
    codeGenOpts.addOption(OptionBuilder.withArgName("null-str").hasArg()
            .withDescription("Null string representation").withLongOpt(NULL_STRING).create());
    codeGenOpts.addOption(OptionBuilder.withArgName("null-str").hasArg()
            .withDescription("Input null string representation").withLongOpt(INPUT_NULL_STRING).create());
    codeGenOpts.addOption(OptionBuilder.withArgName("null-str").hasArg()
            .withDescription("Null non-string representation").withLongOpt(NULL_NON_STRING).create());
    codeGenOpts.addOption(OptionBuilder.withArgName("null-str").hasArg()
            .withDescription("Input null non-string representation").withLongOpt(INPUT_NULL_NON_STRING)
            .create());
    codeGenOpts.addOption(
            OptionBuilder.hasArg().withDescription("Override mapping for specific columns to java types")
                    .withLongOpt(MAP_COLUMN_JAVA).create());

    if (!multiTable) {
        codeGenOpts.addOption(OptionBuilder.withArgName("name").hasArg()
                .withDescription("Sets the generated class name. " + "This overrides --" + PACKAGE_NAME_ARG
                        + ". When combined " + "with --" + JAR_FILE_NAME_ARG + ", sets the input class.")
                .withLongOpt(CLASS_NAME_ARG).create());
    }

    codeGenOpts.addOption(OptionBuilder.withArgName(INVALID_IDENTIFIER_PREFIX).hasArg()
            .withDescription("Set the prefix for invalid table/column identifiers")
            .withLongOpt(INVALID_IDENTIFIER_PREFIX).create());

    return codeGenOpts;
}

From source file:org.apache.storm.command.OptionsProcessor.java

public OptionsProcessor() {

    // -t topologyname
    options.addOption(OptionBuilder.hasArg().withArgName("topologyname").withLongOpt("topologyname")
            .withDescription("Specify the topologyname to submit").create('t'));

    // -w waitsecs
    options.addOption(OptionBuilder.hasArg().withArgName("waitsecs").withLongOpt("waitsecs")
            .withDescription("waitsecs").create('w'));

    // -n numworkers
    options.addOption(OptionBuilder.hasArg().withArgName("numworkers").withLongOpt("numworkers")
            .withDescription("numworkers").create('n'));

    // -v key=value -v key=value
    options.addOption(OptionBuilder.withValueSeparator().hasArgs(2).withArgName("key=value").withLongOpt("var")
            .withDescription("Variable subsitution to apply to Storm commands. e.g. -v A=B -v C=D")
            .create('v'));

    // -c command
    options.addOption(OptionBuilder.hasArg().withArgName("command").withLongOpt("command")
            .withDescription("command").create('c'));

    // -p path/*from w ww.  j  a va2  s.co m*/
    options.addOption(
            OptionBuilder.hasArg().withArgName("path").withLongOpt("path").withDescription("path").create('p'));

}

From source file:org.apache.usergrid.launcher.Server.java

static Options createOptions() {
    // the nogui option will be required due to combining the graphical
    // launcher with this standalone CLI based server
    Options options = new Options();
    OptionBuilder.withDescription("Start launcher without UI");
    OptionBuilder.isRequired(true);/*from   www.  j av a  2s. c om*/
    Option noguiOption = OptionBuilder.create("nogui");

    OptionBuilder.isRequired(false);
    OptionBuilder.withDescription("Initialize database");
    Option initOption = OptionBuilder.create("init");

    OptionBuilder.withDescription("Start database");
    Option dbOption = OptionBuilder.create("db");

    OptionBuilder.withDescription("Http port (without UI)");
    OptionBuilder.hasArg();
    OptionBuilder.withArgName("PORT");
    OptionBuilder.withLongOpt("port");
    OptionBuilder.withType(Number.class);
    Option portOption = OptionBuilder.create('p');

    options.addOption(initOption);
    options.addOption(dbOption);
    options.addOption(portOption);
    options.addOption(noguiOption);

    return options;
}

From source file:org.apache.usergrid.tools.ExportAdmins.java

@Override
@SuppressWarnings("static-access")
public Options createOptions() {

    Options options = super.createOptions();

    Option readThreads = OptionBuilder.hasArg().withType(0)
            .withDescription("Read Threads -" + READ_THREAD_COUNT).create(READ_THREAD_COUNT);

    options.addOption(readThreads);//  w  w  w .  j  a  v a 2s.  c o  m
    return options;
}