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:de.uni_koblenz.jgralab.utilities.tgschema2java.TgSchema2Java.java

private static CommandLine processCommandLineOptions(String[] args) {
    String toolString = "java " + TgSchema2Java.class.getName();
    String versionString = JGraLab.getInfo(false);
    OptionHandler oh = new OptionHandler(toolString, versionString);

    Option filename = new Option("s", "schema", true,
            "(required): specifies the .tg-file of the schema to be converted");
    filename.setRequired(true);/*from   ww w.  java  2s.  com*/
    filename.setArgName("file");
    oh.addOption(filename);

    Option compile = new Option("c", "compile", false, "(optional): if specified, the .java are compiled");
    compile.setRequired(false);
    oh.addOption(compile);

    Option jar = new Option("j", "jar", true,
            "(optional): specifies the name of the .jar-file; if omitted, no jar will be created");
    jar.setRequired(false);
    jar.setArgName("file");
    oh.addOption(jar);

    Option without_types = new Option("w", "without-types", false,
            "(optional): Don't create typespecific methods in classes");
    without_types.setRequired(false);
    oh.addOption(without_types);

    Option path = new Option("p", "path", true,
            "specifies the path to where the created files are stored; default is current folder (\".\")");
    path.setRequired(true);
    path.setArgName("path");
    oh.addOption(path);

    return oh.parse(args);
}

From source file:com.tc.config.schema.setup.BaseConfigurationSetupManagerTest.java

private static Options createOptions(ConfigMode configMode) {
    Options options = new Options();

    Option configFileOption = new Option("f", CONFIG_SPEC_ARGUMENT_NAME, true,
            "the configuration file to use, specified as a file path or URL");
    configFileOption.setArgName("file-or-URL");
    configFileOption.setType(String.class);

    if (configMode == ConfigMode.L2) {
        configFileOption.setRequired(false);
        options.addOption(configFileOption);

        Option l2NameOption = new Option("n", "name", true, "the name of this L2; defaults to the host name");
        l2NameOption.setRequired(false);
        l2NameOption.setArgName("l2-name");
        options.addOption(l2NameOption);
    } else {/*from  w  w w .  j a  v a2s  .c  o  m*/
        configFileOption.setRequired(true);
        options.addOption(configFileOption);
    }

    return options;
}

From source file:com.facebook.LinkBench.LinkBenchDriver.java

private static Options initializeOptions() {
    Options options = new Options();
    Option config = new Option("c", true, "Linkbench config file");
    config.setArgName("file");
    options.addOption(config);/*from   w  w  w  .j  av a2s  . co  m*/

    Option log = new Option("L", true, "Log to this file");
    log.setArgName("file");
    options.addOption(log);

    Option csvStats = new Option("csvstats", "csvstats", true, "CSV stats output");
    csvStats.setArgName("file");
    options.addOption(csvStats);

    Option csvStream = new Option("csvstream", "csvstream", true, "CSV streaming stats output");
    csvStream.setArgName("file");
    options.addOption(csvStream);

    options.addOption("l", false, "Execute loading stage of benchmark");
    options.addOption("r", false, "Execute request stage of benchmark");

    // Java-style properties to override config file
    // -Dkey=value
    Option property = new Option("D", "Override a config setting");
    property.setArgs(2);
    property.setArgName("property=value");
    property.setValueSeparator('=');
    options.addOption(property);

    return options;
}

From source file:com.msd.gin.halyard.tools.HalyardExport.java

private static Option newOption(String opt, String argName, String description) {
    Option o = new Option(opt, null, argName != null, description);
    o.setArgName(argName);
    return o;//  ww  w.j ava2 s .com
}

From source file:com.linkedin.helix.mock.storage.DummyProcess.java

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

    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)");

    Option cmTypeOption = OptionBuilder.withLongOpt(helixManagerType)
            .withDescription("Provide cluster manager type (e.g. 'zk', 'static-file', or 'dynamic-file'")
            .create();
    cmTypeOption.setArgs(1);
    cmTypeOption.setRequired(true);
    cmTypeOption.setArgName("Clsuter manager type (e.g. 'zk', 'static-file', or 'dynamic-file') (Required)");

    // add an option group including either --zkSvr or --clusterViewFile
    Option fileOption = OptionBuilder.withLongOpt(clusterViewFile)
            .withDescription("Provide a cluster-view file for static-file based cluster manager").create();
    fileOption.setArgs(1);
    fileOption.setRequired(true);
    fileOption.setArgName("Cluster-view file (Required for static-file based cluster manager)");

    Option zkServerOption = OptionBuilder.withLongOpt(zkServer).withDescription("Provide zookeeper address")
            .create();
    zkServerOption.setArgs(1);
    zkServerOption.setRequired(true);
    zkServerOption.setArgName("ZookeeperServerAddress(Required for zk-based cluster manager)");

    //    Option rootNsOption = OptionBuilder.withLongOpt(rootNamespace)
    //        .withDescription("Provide root namespace for dynamic-file based cluster manager").create();
    //    rootNsOption.setArgs(1);
    //    rootNsOption.setRequired(true);
    //    rootNsOption.setArgName("Root namespace (Required for dynamic-file based cluster manager)");

    Option transDelayOption = OptionBuilder.withLongOpt(transDelay).withDescription("Provide state trans delay")
            .create();
    transDelayOption.setArgs(1);
    transDelayOption.setRequired(false);
    transDelayOption.setArgName("Delay time in state transition, in MS");

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

    Options options = new Options();
    options.addOption(helpOption);
    options.addOption(clusterOption);
    options.addOption(hostOption);
    options.addOption(portOption);
    options.addOption(transDelayOption);
    options.addOption(cmTypeOption);

    options.addOptionGroup(optionGroup);

    return options;
}

From source file:fr.inria.atlanmod.instantiator.SpecimenGenerator.java

/**
 * Configures the program options/*from w  ww  .j a va  2s .  c  om*/
 *
 * @param options
 */
private static void configureOptions(Options options) {
    Option metamodelOpt = OptionBuilder.create(METAMODEL);
    metamodelOpt.setLongOpt(METAMODEL_LONG);
    metamodelOpt.setArgName("path_to_metamodel.ecore");
    metamodelOpt.setDescription("Ecore metamodel");
    metamodelOpt.setArgs(1);
    metamodelOpt.setRequired(true);

    Option additionalMetamodelOpt = OptionBuilder.create(ADDITIONAL_METAMODEL);
    additionalMetamodelOpt.setLongOpt(ADDITIONAL_METAMODEL_LONG);
    additionalMetamodelOpt.setArgName("path_to_metamodel.ecore");
    additionalMetamodelOpt.setDescription("Additional ecore metamodel(s) that need to be registered");
    additionalMetamodelOpt.setArgs(Option.UNLIMITED_VALUES);

    Option outDirOpt = OptionBuilder.create(OUTPUT_DIR);
    outDirOpt.setLongOpt(OUTPUT_DIR_LONG);
    outDirOpt.setArgName("path_to_output.dir");
    outDirOpt.setDescription("Output directory (defaults to working dir)");
    outDirOpt.setArgs(1);

    Option nModelsOpt = OptionBuilder.create(N_MODELS);
    nModelsOpt.setLongOpt(N_MODELS_LONG);
    nModelsOpt.setArgName("models");
    nModelsOpt.setDescription("Number of generated models (defaults to 1)");
    nModelsOpt.setType(Number.class);
    nModelsOpt.setArgs(1);

    Option sizeOption = OptionBuilder.create(SIZE);
    sizeOption.setLongOpt(SIZE_LONG);
    sizeOption.setArgName("size");
    sizeOption.setDescription("Models' size (defaults to 1000)");
    sizeOption.setType(Number.class);
    sizeOption.setArgs(1);

    Option seedOption = OptionBuilder.create(SEED);
    seedOption.setLongOpt(SEED_LONG);
    seedOption.setArgName("seed");
    seedOption.setDescription("Seed number (random by default)");
    seedOption.setType(Number.class);
    seedOption.setArgs(1);

    options.addOption(metamodelOpt);
    options.addOption(additionalMetamodelOpt);
    options.addOption(outDirOpt);
    options.addOption(nModelsOpt);
    options.addOption(sizeOption);
    options.addOption(seedOption);
}

From source file:com.springrts.springls.CmdLineArgs.java

private static Options createOptions() {

    Configuration defaults = ServerConfiguration.getDefaults();

    Options options = new Options();

    Option help = new Option(null, "help", false, "Print this help message.");
    options.addOption(help);// ww  w  .  j  a  va 2  s.co m

    Option port = new Option("p", "port", true,
            String.format("The main (TCP) port number to host on [1, 65535]." + " The default is %d.",
                    defaults.getInt(ServerConfiguration.PORT)));
    // possible types:
    // * File.class
    // * Number.class
    // * Class.class
    // * Object.class
    // * Url.class
    port.setType(Number.class);
    port.setArgName("port-number");
    options.addOption(port);

    Option statistics = new Option(null, "statistics", false,
            "Whether to create and save statistics to disc on predefined" + " intervals.");
    options.addOption(statistics);

    Option natPort = new Option("n", "nat-port", true,
            String.format(
                    "The (UDP) port number to host the NAT traversal techniques"
                            + " help service on [1, 65535], which lets clients detect their"
                            + " source port, for example when using \"hole punching\"." + " The default is %d.",
                    defaults.getInt(ServerConfiguration.NAT_PORT)));
    port.setType(Number.class);
    natPort.setArgName("NAT-port-number");
    options.addOption(natPort);

    Option logMain = new Option(null, "log-main", false,
            String.format("Whether to log all conversations from channel #main to \"%s\"",
                    Channel.createDefaultActivityLogFilePath("main").getPath()));
    options.addOption(logMain);

    Option lanAdmin = new Option(null, "lan-admin", true,
            String.format(
                    "The LAN mode admin account. Use this account to administer"
                            + " your LAN server. The default is \"%s\", with password \"%s\".",
                    defaults.getString(ServerConfiguration.LAN_ADMIN_USERNAME),
                    defaults.getString(ServerConfiguration.LAN_ADMIN_PASSWORD)));
    lanAdmin.setArgName("username");
    options.addOption(lanAdmin);

    Option loadArgs = new Option(null, "load-args", true,
            "Will read command-line arguments from the specified file."
                    + " You can freely combine actual command-line arguments with"
                    + " the ones from the file. If duplicate args are specified,"
                    + " the last one will prevail.");
    loadArgs.setArgName("filename");
    port.setType(File.class);
    options.addOption(loadArgs);

    Option springVersion = new Option(null, "spring-version", true,
            "Will set the latest Spring version to this string."
                    + " The default is \"*\". This is used to tell clients which"
                    + " version is the latest one, so that they know when to" + " update.");
    springVersion.setArgName("version");
    options.addOption(springVersion);

    Option useStorageDb = new Option(null, "database", false,
            "Use a DB for user accounts and ban entries." + " This disables \"LAN mode\".");
    options.addOption(useStorageDb);

    Option useStorageFile = new Option(null, "file-storage", false,
            "Use the (deprecated) accounts.txt for user accounts." + " This disables \"LAN mode\".");
    options.addOption(useStorageFile);

    OptionGroup storageOG = new OptionGroup();
    storageOG.addOption(useStorageDb);
    storageOG.addOption(useStorageFile);
    options.addOptionGroup(storageOG);

    return options;
}

From source file:de.uni_koblenz.ist.utilities.license_header.LicenseHeader.java

private static CommandLine processCommandLineOptions(String[] args) {
    OptionHandler oh = new OptionHandler("java " + LicenseHeader.class.getName(), "1.0");
    Option input = new Option("i", "input", true, "(required): The file or directory to process.");
    // input.setArgs(1);
    input.setRequired(true);/*from  ww w  . ja  v a 2  s  .  co  m*/
    input.setArgName("fileOrDirectory");
    oh.addOption(input);

    Option licenceHeader = new Option("l", "licence", true,
            "(required): The file containing the licence header in the correct format. This file should be in plain text without any language specific syntax for comments.");
    // licenceHeader.setArgs(1);
    licenceHeader.setRequired(true);
    licenceHeader.setArgName("licenseFile");
    oh.addOption(licenceHeader);

    // TODO add this feature
    // Option fileType = new Option(
    // "x",
    // "--xml",
    // false,
    // "(optional): This flag tells the program to operate on xml files instead of java files (experimental).");
    // fileType.setRequired(false);
    // oh.addOption(fileType);

    Option recursive = new Option("r", "recursive", false,
            "(optional): This flag tells the program to process the given directory fully recursively. If only a file is given, this option is ignored. If this flag is not set, only the given directory is processed, without subdirectories.");
    recursive.setRequired(false);
    oh.addOption(recursive);

    Option verbose = new Option("V", "verbose", false,
            "(optional): This flag tells the program to be more verbose while processing the files. If it is not set, only a summary will be given in the end.");
    verbose.setRequired(false);
    oh.addOption(verbose);

    return oh.parse(args);
}

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

/**
 * Parse command-line arguments./*w ww. 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();

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

    // Whether to skip existing files or not.
    o = new Option("r", "reprocess", false,
            "Reprocess only those records that have been marked to be reprocessed. Otherwise process all rows indicated in the processing records, but successfully processed job files are skipped.");
    o.setRequired(false);
    options.addOption(o);

    // Whether to aggregate or not.
    // if re-process is on, need to consider turning aggregation off
    o = new Option("a", "aggregate", true, "Whether to aggreagate job details or not.");
    o.setArgName("aggreagte");
    o.setRequired(false);
    options.addOption(o);

    // Whether to force re-aggregation or not.
    o = new Option("ra", "re-aggregate", true, "Whether to re-aggreagate job details or not.");
    o.setArgName("re-aggreagte");
    o.setRequired(false);
    options.addOption(o);

    // Batch
    o = new Option("b", "batchSize", true,
            "The number of files to process in one batch. Default " + DEFAULT_BATCH_SIZE);
    o.setArgName("batch-size");
    o.setRequired(false);
    options.addOption(o);

    o = new Option("t", "threads", true,
            "Number of parallel threads to use to run Hadoop jobs simultaniously. Default = 1");
    o.setArgName("thread-count");
    o.setRequired(false);
    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);

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

    o = new Option("zf", "costFile", true, "The cost properties file location on HDFS");
    o.setArgName("costfile_loc");
    o.setRequired(true);
    options.addOption(o);

    // Machine type
    o = new Option("m", "machineType", true, "The type of machine this job ran on");
    o.setArgName("machinetype");
    o.setRequired(true);
    options.addOption(o);

    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(JobFileProcessor.class);
        log.setLevel(Level.DEBUG);
    }

    return commandLine;

}

From source file:de.zib.scalaris.InterOpTest.java

/**
 * Creates the options the command line should understand.
 *
 * @return the options the program understands
 *///from w ww  . j  av  a  2 s  .c o  m
private static Options getOptions() {
    final Options options = new Options();
    final OptionGroup group = new OptionGroup();

    /* Note: arguments are set to be optional since we implement argument
     * checks on our own (commons.cli is not flexible enough and only
     * checks for the existence of a first argument)
     */

    options.addOption(new Option("h", "help", false, "print this message"));

    options.addOption(new Option("v", "verbose", false, "print verbose information, e.g. the properties read"));

    final Option read = new Option("r", "read", true, "read an item");
    read.setArgName("basekey> <language");
    read.setArgs(2);
    read.setOptionalArg(true);
    group.addOption(read);

    final Option write = new Option("w", "write", true, "write an item");
    write.setArgName("basekey");
    write.setArgs(1);
    write.setOptionalArg(true);
    group.addOption(write);

    options.addOptionGroup(group);

    options.addOption(new Option("lh", "localhost", false,
            "gets the local host's name as known to Java (for debugging purposes)"));

    return options;
}