Example usage for org.apache.commons.cli Option setArgName

List of usage examples for org.apache.commons.cli Option setArgName

Introduction

In this page you can find the example usage for org.apache.commons.cli Option setArgName.

Prototype

public void setArgName(String argName) 

Source Link

Document

Sets the display name for the argument value.

Usage

From source file:kieker.develop.rl.cli.CLICompilerMain.java

/**
 * Compile the options for the CLI server.
 *
 * @return The composed options for the CLI server
 *//*from  w  ww . j av a  2  s  .  co m*/
private static Options declareOptions() {
    options = new Options();
    Option option;

    // runtime root
    option = new Option(CMD_ROOT, CMD_ROOT_LONG, true, "Root folder of eclipse platfrom/workspace.");
    option.setArgName(CMD_ROOT);
    option.setRequired(true);
    options.addOption(option);

    // eclipse project name
    option = new Option(CMD_PROJECT, CMD_PROJECT_LONG, true, "Eclipse project containing the files.");
    option.setArgName(CMD_PROJECT);
    option.setRequired(true);
    options.addOption(option);

    // eclipse project path name
    option = new Option(CMD_PROJECT_DIRECTORY, CMD_PROJECT_DIRECTORY_LONG, true,
            "Directory path name of the project (normally determined automatically).");
    option.setArgName(CMD_PROJECT_DIRECTORY);
    option.setRequired(false);
    options.addOption(option);

    // project relative source folder
    option = new Option(CMD_SOURCE, CMD_SOURCE_LONG, true, "Project relative source folder.");
    option.setArgName(CMD_SOURCE);
    option.setRequired(false);
    options.addOption(option);

    // project relative target folder
    option = new Option(CMD_DESTINATION, CMD_DESTINATION_LONG, true, "Project relative destination folder.");
    option.setArgName(CMD_DESTINATION);
    option.setRequired(false);
    options.addOption(option);

    // use language specific target folders
    option = new Option(CMD_MAVEN_FOLDER_LAYOUT, CMD_MAVEN_FOLDER_LAYOUT_LONG, false,
            "Use language specific destination folders (maven layout).");
    option.setArgName(CMD_MAVEN_FOLDER_LAYOUT);
    option.setRequired(false);
    options.addOption(option);

    // select languages
    option = new Option(CMD_LANGUAGES, CMD_LANGUAGES_LONG, true, "Generate code for all named languages.");
    option.setArgName(CMD_LANGUAGES);
    option.setRequired(true);
    options.addOption(option);

    // set author for the generated code
    option = new Option(CMD_AUTHOR, CMD_AUHTOR_LONG, true,
            "Set author name for the generated code. Default is 'generated'.");
    option.setArgName(CMD_AUTHOR);
    option.setRequired(false);
    options.addOption(option);

    // set author for the generated code
    option = new Option(CMD_VERSION, CMD_VERSION_LONG, true,
            "Set version for the generated code. Default is 'none'.");
    option.setArgName(CMD_VERSION);
    option.setRequired(false);
    options.addOption(option);

    return options;
}

From source file:com.ibm.watson.app.qaclassifier.tools.GenerateTrainingAndPopulationData.java

private static Option createOption(String opt, String longOpt, boolean hasArg, String description,
        boolean required, String argName) {
    Option option = new Option(opt, longOpt, hasArg, description);
    option.setRequired(required);//from   w  ww .  j ava  2  s  . c o m
    option.setArgName(argName);
    return option;
}

From source file:com.opengamma.component.tool.AbstractDbTool.java

private static Option createConfigOption() {
    Option option = new Option(CONFIG_RESOURCE_OPTION, "config", true,
            "the database tool context configuration resource");
    option.setArgName("resource");
    option.setRequired(true);/* www .  ja  v a2 s .co m*/
    return option;
}

From source file:com.twitter.hraven.etl.JobFileRawLoader.java

/**
 * Parse command-line arguments.//from  w  w w. j a  v a 2 s .  co m
 * 
 * @param args
 *          command line arguments passed to program.
 * @return parsed command line.
 * @throws ParseException
 */
private static CommandLine parseArgs(String[] args) throws ParseException {
    Options options = new Options();

    // Cluster
    Option o = new Option("c", "cluster", true, "cluster for which jobs are processed");
    o.setArgName("cluster");
    o.setRequired(true);
    options.addOption(o);

    o = new Option("p", "processFileSubstring", true,
            "use only those process records where the process file path contains the provided string. Useful when processing production jobs in parallel to historic loads.");
    o.setArgName("processFileSubstring");
    o.setRequired(false);
    options.addOption(o);

    // Force
    o = new Option("f", "forceReprocess", false,
            "Force all jobs for which a jobFile is loaded to be reprocessed. Optional. Default is false.");
    o.setRequired(false);
    options.addOption(o);

    // Debugging
    options.addOption("d", "debug", false, "switch on DEBUG log level");

    CommandLineParser parser = new PosixParser();
    CommandLine commandLine = null;
    try {
        commandLine = parser.parse(options, args);
    } catch (Exception e) {
        System.err.println("ERROR: " + e.getMessage() + "\n");
        HelpFormatter formatter = new HelpFormatter();
        formatter.printHelp(NAME + " ", options, true);
        System.exit(-1);
    }

    // Set debug level right away
    if (commandLine.hasOption("d")) {
        Logger log = Logger.getLogger(JobFileRawLoader.class);
        log.setLevel(Level.DEBUG);
    }

    return commandLine;
}

From source file:com.opengamma.component.tool.AbstractComponentTool.java

private static Option createComponentServerOption() {
    Option option = new Option(COMPONENT_SERVER_URI_OPTION, "componentServer", true,
            "the component server, host[:port]");
    option.setArgName("component server");
    option.setRequired(true);//from  w  w  w.j  av  a2 s . c o m
    return option;
}

From source file:com.linkedin.helix.mock.relay.DummyRelayProcess.java

@SuppressWarnings("static-access")
private static Options constructCommandLineOptions() {
    Option helpOption = OptionBuilder.withLongOpt(help).withDescription("Prints command-line options info")
            .create();/* w w w.  j  a v a2 s  . c  o  m*/

    Option zkServerOption = OptionBuilder.withLongOpt(zkServer).withDescription("Provide zookeeper address")
            .create();
    zkServerOption.setArgs(1);
    zkServerOption.setRequired(true);
    zkServerOption.setArgName("ZookeeperServerAddress(Required)");

    Option clusterOption = OptionBuilder.withLongOpt(cluster).withDescription("Provide cluster name").create();
    clusterOption.setArgs(1);
    clusterOption.setRequired(true);
    clusterOption.setArgName("Cluster name (Required)");

    Option hostOption = OptionBuilder.withLongOpt(hostAddress).withDescription("Provide host name").create();
    hostOption.setArgs(1);
    hostOption.setRequired(true);
    hostOption.setArgName("Host name (Required)");

    Option portOption = OptionBuilder.withLongOpt(hostPort).withDescription("Provide host port").create();
    portOption.setArgs(1);
    portOption.setRequired(true);
    portOption.setArgName("Host port (Required)");

    // add an option group including either --zkSvr or --configFile
    Option fileOption = OptionBuilder.withLongOpt(configFile)
            .withDescription("Provide file to read states/messages").create();
    fileOption.setArgs(1);
    fileOption.setRequired(true);
    fileOption.setArgName("File to read states/messages (Optional)");

    OptionGroup optionGroup = new OptionGroup();
    optionGroup.addOption(zkServerOption);
    optionGroup.addOption(fileOption);

    Options options = new Options();
    options.addOption(helpOption);
    // options.addOption(zkServerOption);
    options.addOption(clusterOption);
    options.addOption(hostOption);
    options.addOption(portOption);

    options.addOptionGroup(optionGroup);

    return options;
}

From source file:net.sf.markov4jmeter.behaviormodelextractor.CmdlOptionFactory.java

/**
 * Creates an option with a specified number of arguments;
 *
 * @param opt//from ww  w .j a  v  a  2 s  .  c  o  m
 *     Short representation of the option (e.g. <code>"s"</code>).
 * @param longOpt
 *     Long representation of the option
 *     (e.g. <code>"source-project"</code>).
 * @param description
 *     Description of the option
 *     (e.g. <code>"Path to source project."</code>).
 * @param isRequired
 *     Flag indicating whether the option is required (as a command-line
 *     argument) or not.
 * @param argName
 *     Display name for the argument value.
 * @param argsNum
 *     Number of arguments; a negative value indicates an infinite sequence
 *     of arguments.
 * @param hasOptionalArg
 *     <code>true</code> if and only if the arguments are optional.
 * @return
 *     An instance of {@link Option} with the specified properties.
 */
public static Option createOption(final String opt, final String longOpt, final String description,
        final boolean isRequired, final String argName, final int argsNum, final boolean hasOptionalArg) {

    final Option option = new Option(opt, longOpt, argsNum != 0 /* hasArg */, description);

    option.setRequired(isRequired);

    if (argsNum != 0) { // argsNum < 0 for infinite sequence of arguments;

        if (argName != null) {
            option.setArgName(argName);
        }
        // negative number of arguments implies an infinite sequence;
        option.setArgs((argsNum < 0) ? Integer.MAX_VALUE : argsNum);

        option.setValueSeparator(CmdlOptionFactory.DEFAULT_VALUE_SEPARATOR);
        option.setOptionalArg(hasOptionalArg);
    }
    return option;
}

From source file:com.linkedin.helix.MockEspressoService.java

@SuppressWarnings("static-access")
private static Options constructCommandLineOptions() {
    Option helpOption = OptionBuilder.withLongOpt(HELP).withDescription("Prints command-line options info")
            .create();/*from  ww w. j a va2s .c om*/
    helpOption.setArgs(0);
    helpOption.setRequired(false);
    helpOption.setArgName("print help message");

    Option zkServerOption = OptionBuilder.withLongOpt(ZKSERVERADDRESS)
            .withDescription("Provide zookeeper address").create();
    zkServerOption.setArgs(1);
    zkServerOption.setRequired(true);
    zkServerOption.setArgName("ZookeeperServerAddress(Required)");

    Option clusterOption = OptionBuilder.withLongOpt(CLUSTERNAME).withDescription("Provide cluster name")
            .create();
    clusterOption.setArgs(1);
    clusterOption.setRequired(true);
    clusterOption.setArgName("Cluster name(Required)");

    Option instanceOption = OptionBuilder.withLongOpt(INSTANCENAME)
            .withDescription("Provide name for this instance").create();
    instanceOption.setArgs(1);
    instanceOption.setRequired(false);
    instanceOption.setArgName("Instance name(Optional, defaults to localhost)");

    Option portOption = OptionBuilder.withLongOpt(PORT).withDescription("Provide web service port").create();
    portOption.setArgs(1);
    portOption.setRequired(false);
    portOption.setArgName("web service port, default: " + DEFAULT_PORT);

    Options options = new Options();
    options.addOption(helpOption);
    options.addOption(zkServerOption);
    options.addOption(clusterOption);
    options.addOption(instanceOption);
    options.addOption(portOption);

    return options;
}

From source file:com.linkedin.helix.controller.HelixControllerMain.java

@SuppressWarnings("static-access")
synchronized private static Options constructCommandLineOptions() {
    Option helpOption = OptionBuilder.withLongOpt(help).withDescription("Prints command-line options info")
            .create();//from ww  w . j ava 2 s .c o m

    Option zkServerOption = OptionBuilder.withLongOpt(zkServerAddress)
            .withDescription("Provide zookeeper address").create();
    zkServerOption.setArgs(1);
    zkServerOption.setRequired(true);
    zkServerOption.setArgName("ZookeeperServerAddress(Required)");

    Option clusterOption = OptionBuilder.withLongOpt(cluster).withDescription("Provide cluster name").create();
    clusterOption.setArgs(1);
    clusterOption.setRequired(true);
    clusterOption.setArgName("Cluster name (Required)");

    Option modeOption = OptionBuilder.withLongOpt(mode)
            .withDescription("Provide cluster controller mode (Optional): STANDALONE (default) or DISTRIBUTED")
            .create();
    modeOption.setArgs(1);
    modeOption.setRequired(false);
    modeOption.setArgName("Cluster controller mode (Optional)");

    Option controllerNameOption = OptionBuilder.withLongOpt(name)
            .withDescription("Provide cluster controller name (Optional)").create();
    controllerNameOption.setArgs(1);
    controllerNameOption.setRequired(false);
    controllerNameOption.setArgName("Cluster controller name (Optional)");

    Option portOption = OptionBuilder.withLongOpt(propertyTransferServicePort)
            .withDescription("Webservice port for ZkProperty controller transfer").create();
    portOption.setArgs(1);
    portOption.setRequired(false);
    portOption.setArgName("Cluster controller property transfer port (Optional)");

    Options options = new Options();
    options.addOption(helpOption);
    options.addOption(zkServerOption);
    options.addOption(clusterOption);
    options.addOption(modeOption);
    options.addOption(portOption);
    options.addOption(controllerNameOption);

    return options;
}

From source file:com.opengamma.component.tool.AbstractDualComponentTool.java

private static Option createSourceComponentServerOption() {
    Option option = new Option(SRC_COMPONENT_SERVER_URI_OPTION, "source-component-server", true,
            "the source component server, host[:port]");
    option.setArgName("source component server");
    option.setRequired(true);//from  ww w  .  j  a  v  a 2 s.c o  m
    return option;
}