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:org.ow2.proactive_grid_cloud_portal.cli.CommandFactory.java

protected Options createOptions(Collection<CommandSet.Entry> entries) {
    Options options = new Options();

    for (CommandSet.Entry entry : entries) {
        Option option = new Option(entry.opt(), entry.longOpt(), entry.hasArgs(), entry.description());

        option.setArgName(entry.argNames());
        option.setArgs(entry.numOfArgs());
        option.setOptionalArg(entry.hasOptionalArg());

        options.addOption(option);//from   w  w  w .j a v  a  2s.c  om
    }
    return options;
}

From source file:org.rapidcontext.app.Main.java

/**
 * Application entry point./*from ww  w .ja v a2  s  .co  m*/
 *
 * @param args           the command-line parameters
 */
public static void main(String[] args) {
    Options options = new Options();
    OptionGroup grp;
    Option opt;
    CommandLine cli;

    // Create main command-line options
    grp = new OptionGroup();
    opt = new Option(null, "app", false, "Launch in interactive application mode.");
    grp.addOption(opt);
    opt = new Option(null, "server", false, "Launch in server mode.");
    grp.addOption(opt);
    opt = new Option(null, "script", false, "Launch in script execution mode.");
    grp.addOption(opt);
    options.addOptionGroup(grp);

    // Create other command-line options
    options.addOption("h", "help", false, "Displays this help message,");
    opt = new Option("l", "local", true, "Use a specified local app directory.");
    opt.setArgName("dir");
    options.addOption(opt);
    opt = new Option("p", "port", true, "Use a specified port number (non-script mode).");
    opt.setArgName("number");
    options.addOption(opt);
    opt = new Option("d", "delay", true, "Add a delay after each command (script mode).");
    opt.setArgName("secs");
    options.addOption(opt);
    options.addOption("t", "trace", false, "Print detailed execution trace (script mode).");
    opt = new Option("u", "user", true, "Authenticate as a another user (script mode).");
    opt.setArgName("name");
    options.addOption(opt);
    options.addOption(null, "stdin", false, "Read commands from stdin (script mode).");
    opt = new Option("f", "file", true, "Read commands from a file (script mode).");
    opt.setArgName("file");
    options.addOption(opt);

    // Parse command-line arguments
    try {
        cli = new DefaultParser().parse(options, args);
        if (cli.hasOption("help")) {
            exit(options, null);
        }
        args = cli.getArgs();
        if (cli.hasOption("app")) {
            runApp(cli, args, options);
        } else if (cli.hasOption("server")) {
            runServer(cli, args, options);
        } else if (cli.hasOption("script")) {
            runScript(cli, args, options);
        } else if (args.length == 0 && !SystemUtils.isJavaAwtHeadless()) {
            runApp(cli, args, options);
        } else {
            runScript(cli, args, options);
        }
    } catch (ParseException e) {
        exit(options, e.getMessage());
    }
}

From source file:org.rhq.storage.installer.StorageInstaller.java

public StorageInstaller() {
    String basedir = System.getProperty("rhq.server.basedir");
    serverBasedir = new File(basedir);
    storageBasedir = new File(basedir, STORAGE_BASEDIR);

    Option hostname = new Option("n", StorageProperty.HOSTNAME.property(), true,
            "The hostname or IP address on which the node will listen for "
                    + "requests. Note that if a hostname is specified, the IP address is used. Defaults to the IP "
                    + "address of the local host (which depending on hostname configuration may not be localhost).");
    hostname.setArgName("HOSTNAME");

    Option seeds = new Option("s", StorageProperty.SEEDS.property(), true,
            "A comma-delimited list of hostnames or IP addresses that "
                    + "serve as contact points. Nodes use this list to find each other and to learn the cluster topology. "
                    + "It does not need to specify all nodes in the cluster. Defaults to this node's hostname.");
    seeds.setArgName("SEEDS");

    Option jmxPortOption = new Option("j", StorageProperty.JMX_PORT.property(), true,
            "The port on which to listen for JMX connections. " + "Defaults to " + defaultJmxPort + ".");
    jmxPortOption.setArgName("PORT");

    Option cqlPortOption = new Option("c", StorageProperty.CQL_PORT.property(), true,
            "The port on which to " + "listen for client requests. Defaults to " + defaultCqlPort);
    cqlPortOption.setArgName("PORT");

    Option gossipPortOption = new Option(null, StorageProperty.GOSSIP_PORT.property(), true,
            "The port on which to listen for requests " + " from other nodes. Defaults to "
                    + defaultGossipPort);
    gossipPortOption.setArgName("PORT");

    Option startOption = new Option(null, "start", true,
            "Start the storage node after installing it on disk. " + "Defaults to true.");
    startOption.setArgName("true|false");

    Option checkStatus = new Option(null, "check-status", true, "Check the node status to verify that it is up "
            + "after starting it. This option is ignored if the start option is not set. Defaults to true.");
    checkStatus.setArgName("true|false");

    Option commitLogOption = new Option(null, StorageProperty.COMMITLOG.property(), true,
            "The directory where the storage node keeps " + "commit log files. Defaults to "
                    + getDefaultCommitLogDir() + ".");
    commitLogOption.setArgName("DIR");

    Option dataDirOption = new Option(null, StorageProperty.DATA.property(), true,
            "The directory where the storage node keeps data files. " + "Defaults to " + getDefaultDataDir()
                    + ".");
    dataDirOption.setArgName("DIR");

    Option savedCachesDirOption = new Option(null, StorageProperty.SAVED_CACHES.property(), true,
            "The directory where the storage node " + "keeps saved cache files. Defaults to "
                    + getDefaultSavedCachesDir() + ".");
    savedCachesDirOption.setArgName("DIR");

    Option basedirOption = new Option(null, "dir", true,
            "The directory where the storage node will be installed " + "The default directory will be "
                    + storageBasedir);/*from w w w  .j  a  v a  2 s .com*/

    Option heapSizeOption = new Option(null, StorageProperty.HEAP_SIZE.property(), true,
            "The value to use for both the min and max heap. "
                    + "This value is passed directly to the -Xms and -Xmx options of the Java executable. Defaults to "
                    + defaultHeapSize);

    Option heapNewSizeOption = new Option(null, StorageProperty.HEAP_NEW_SIZE.property(), true,
            "The value to use for the new generation "
                    + "of the heap. This value is passed directly to the -Xmn option of the Java executable. Defaults to "
                    + defaultHeapNewSize);

    Option stackSizeOption = new Option(null, StorageProperty.STACK_SIZE.property(), true,
            "The value to use for the thread stack size. "
                    + "This value is passed directly to the -Xss option of the Java executable.");

    Option upgradeOption = new Option(null, "upgrade", true, "Upgrades an existing storage node. The directory "
            + "where the existing RHQ server is installed.");
    upgradeOption.setArgName("RHQ_SERVER_DIR");

    Option verifyDataDirsEmptyOption = new Option(null, StorageProperty.VERIFY_DATA_DIRS_EMPTY.property(), true,
            "Will cause the installer "
                    + "to abort if any of the data directories is not empty. Defaults to true.");

    options = new Options().addOption(new Option("h", "help", false, "Show this message.")).addOption(hostname)
            .addOption(seeds).addOption(jmxPortOption).addOption(startOption).addOption(checkStatus)
            .addOption(commitLogOption).addOption(dataDirOption).addOption(savedCachesDirOption)
            .addOption(cqlPortOption).addOption(gossipPortOption).addOption(basedirOption)
            .addOption(heapSizeOption).addOption(heapNewSizeOption).addOption(stackSizeOption)
            .addOption(upgradeOption).addOption(verifyDataDirsEmptyOption);
}

From source file:org.sat4j.sat.Lanceur.java

public static Options createCLIOptions() {
    Options options = new Options();
    options.addOption("l", "library", true, "specifies the name of the library used (minisat by default)");
    options.addOption("s", "solver", true, "specifies the name of a prebuilt solver from the library");
    options.addOption("S", "Solver", true, "setup a solver using a solver config string");
    options.addOption("t", "timeout", true, "specifies the timeout (in seconds)");
    options.addOption("T", "timeoutms", true, "specifies the timeout (in milliseconds)");
    options.addOption("C", "conflictbased", false, "conflict based timeout (for deterministic behavior)");
    options.addOption("d", "dot", true,
            "creates a sat4j.dot file in current directory representing the search");
    options.addOption("f", "filename", true, "specifies the file to use (in conjunction with -d for instance)");
    options.addOption("m", "mute", false, "Set launcher in silent mode");
    options.addOption("k", "kleast", true,
            "limit the search to models having at least k variables set to false");
    options.addOption("r", "trace", false, "traces the behavior of the solver");
    options.addOption("opt", "optimize", false, "uses solver in optimize mode instead of sat mode (default)");
    options.addOption("rw", "randomWalk", true, "specifies the random walk probability ");
    options.addOption("remote", "remoteControl", false, "launches remote control");
    options.addOption("H", "hot", false, "keep the solver hot (do not reset heuristics) when a model is found");
    options.addOption("y", "simplify", false, "simplify the set of clauses is possible");
    Option op = options.getOption("l");
    op.setArgName("libname");
    op = options.getOption("s");
    op.setArgName("solvername");
    op = options.getOption("S");
    op.setArgName("solverStringDefinition");
    op = options.getOption("t");
    op.setArgName(NUMBER);/*  www .  j  a  v a2s. com*/
    op = options.getOption("T");
    op.setArgName(NUMBER);
    op = options.getOption("C");
    op.setArgName(NUMBER);
    op = options.getOption("k");
    op.setArgName(NUMBER);
    op = options.getOption("d");
    op.setArgName("filename");
    op = options.getOption("f");
    op.setArgName("filename");
    op = options.getOption("r");
    op.setArgName("searchlistener");
    op = options.getOption("rw");
    op.setArgName(NUMBER);
    return options;
}

From source file:org.shaf.core.process.cmd.CommandOptionHandler.java

/**
 * Generates a command line option for the specified
 * {@code SingleOptionInfo}.//from  w  ww .ja v a2 s.  c o m
 * 
 * @param singleOptionInfo
 *            the specified {@code SingleOptionInfo}.
 * @return the generated command line option.
 */
private static Option generate(final SingleOptionInfo singleOptionInfo) {
    Option option = new Option(singleOptionInfo.getName(), singleOptionInfo.getArg() != null,
            singleOptionInfo.getDescr());

    if (singleOptionInfo.getArg() != null) {
        option.setArgName(singleOptionInfo.getArg());
    }
    option.setRequired(singleOptionInfo.isRequired());

    return option;
}

From source file:org.speechforge.cairo.demo.tts.SpeechSynthClient.java

private static Options getOptions() {
    Options options = ResourceImpl.getOptions();

    Option option = new Option(BEEP_OPTION, "play response/event timing beep");
    options.addOption(option);/*  w w  w.j  av  a 2s  .c  om*/

    option = new Option(URL_OPTION, "play the wave or text file at the given url");
    options.addOption(option);

    option = new Option(REPETITIONS_OPTION, true, "number of times to repeat the TTS prompt");
    option.setArgName("repetitions");
    options.addOption(option);

    return options;
}

From source file:org.speechforge.cairo.server.resource.ResourceImpl.java

public static Options getOptions() {
    Options options = new Options();

    Option option = new Option(HELP_OPTION, "print this message");
    options.addOption(option);/*from   ww w  .  j  a v  a  2 s .  com*/

    option = new Option(RSERVERHOST_OPTION, true, "location of resource server (defaults to localhost)");
    option.setArgName("host");
    options.addOption(option);

    option = new Option(LOCALHOST_OPTION, true, "location of local server (defaults to localhost)");
    option.setArgName("lhost");
    options.addOption(option);

    return options;
}

From source file:org.sybila.parasim.application.ParasimOptions.java

public static Options getOptions() {
    if (options == null) {
        Option config = new Option("c", "config", true,
                "specify config file, it uses 'parasim.xml' if not specified");
        config.setArgName("file");
        Option experiment = new Option("e", "experiment", true, "specify experiment properties file");
        experiment.setArgName("file");
        Option result = new Option("r", "result", false, "do not execute experiment, only print result");
        Option help = new Option("h", "help", false, "show help");
        Option version = new Option("v", "version", false, "show version");
        Option cvs = new Option("csv", "csv", true, "specify CSV file");
        cvs.setArgName("file");
        Option batch = new Option("b", "batch", false, "skip result plotter");
        Option server = new Option("s", "server", false, "start Parasim server only");
        Option terminal = new Option("t", "terminal", false, "use command line interface");
        options = new Options().addOption(config).addOption(experiment).addOption(result).addOption(help)
                .addOption(version).addOption(cvs).addOption(batch).addOption(server).addOption(terminal);
    }/*from w  w w  . j  a  va 2s .  co m*/
    return options;
}

From source file:org.tuxedoberries.transformo.app.frontend.CommandLineLauncher.java

public static Options getOptions() {
    Options options = new Options();
    options.addOption("help", "Print this message.");

    // Generation
    OptionGroup genGroup = new OptionGroup();
    Option tablesOption = new Option("tables", "Generate filled templates by using each table information.");
    Option fieldsOption = new Option("fields", "Generate filled templates by using each field information.");
    Option dataOption = new Option("data", "Generate data using a specific format.");
    genGroup.addOption(tablesOption);/*  ww  w . j av  a 2  s.  co m*/
    genGroup.addOption(fieldsOption);
    genGroup.addOption(dataOption);
    genGroup.setRequired(true);
    options.addOptionGroup(genGroup);

    // Database
    Option database = new Option("d", "Use the given Database. Just XLSX format Supported for now.");
    database.setArgs(1);
    database.setArgName("file");
    database.setRequired(true);
    options.addOption(database);

    // Target Folder
    Option targetFolder = new Option("tfolder", "Target folder where to save the result.");
    targetFolder.setArgs(1);
    targetFolder.setArgName("folder");
    options.addOption(targetFolder);

    // Target File
    Option targetFile = new Option("tfile",
            "Target file name expresion. For -tables or -fields can use $file_name$, $field_name$ and/or $field_type$ and any modifiers.");
    targetFile.setArgs(1);
    targetFile.setArgName("file");
    options.addOption(targetFile);

    // Target Format
    OptionGroup formatGroup = new OptionGroup();
    Option jsonOption = new Option("json", "[-data only] Generate data using JSON format.");
    Option shortJsonOption = new Option("sjson",
            "[-data only] Generate data using Short field name JSON format.");
    formatGroup.addOption(jsonOption);
    formatGroup.addOption(shortJsonOption);
    options.addOptionGroup(formatGroup);

    // Template Folder
    Option templateFolder = new Option("sfolder",
            "[-tables or -fields only] Template source folder. Where to locate all different templates to use.");
    templateFolder.setArgs(1);
    templateFolder.setArgName("folder");
    options.addOption(templateFolder);

    // Template File
    Option templateFile = new Option("sfile",
            "[-tables or -fields only] Template index source file. The point of origin for the templates.");
    templateFile.setArgs(1);
    templateFile.setArgName("file");
    options.addOption(templateFile);

    return options;
}