Example usage for org.apache.commons.cli OptionGroup OptionGroup

List of usage examples for org.apache.commons.cli OptionGroup OptionGroup

Introduction

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

Prototype

OptionGroup

Source Link

Usage

From source file:com.github.lindenb.jvarkit.util.command.CommandFactory.java

protected void fillOptions(final Options opts) {
    final OptionGroup g = new OptionGroup();
    g.addOption(createHelpOption());/*from   www.  jav  a2 s.c o  m*/
    g.addOption(createVersionOption());
    g.addOption(Option.builder("proxy").required(false).longOpt("proxy").hasArg(true).argName("HOST:PORT")
            .desc("set the http and the https proxy.").build());
    opts.addOptionGroup(g);
}

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);//from w  ww .j  a v  a 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:com.hp.mqm.atrf.core.configuration.CliParser.java

public CliParser() {
    options.addOption(Option.builder(HELP_OPTION).longOpt(HELP_OPTION_LONG).desc("Show this help").build());
    options.addOption(Option.builder(VERSION_OPTION).longOpt(VERSION_OPTION_LONG)
            .desc("Show version of this tool").build());

    options.addOption(Option.builder(OUTPUT_FILE_OPTION).longOpt(OUTPUT_FILE_OPTION_LONG).desc(
            "Write output to file instead of sending it to ALM Octane. File path is optional. Default file name is '"
                    + DEFAULT_OUTPUT_FILE + "'." + System.lineSeparator()
                    + " When saving to a file, the tool saves first 1000 runs." + System.lineSeparator()
                    + "No ALM Octane URL or authentication configuration is required if you use this option.")
            .hasArg().argName("FILE").optionalArg(true).build());
    options.addOption(Option.builder(CONFIG_FILE_OPTION).longOpt(CONFIG_FILE_OPTION_LONG)
            .desc("Configuration file location. Default configuration file name is '" + DEFAULT_CONF_FILE + "'")
            .hasArg().argName("FILE").build());

    OptionGroup passAlmGroup = new OptionGroup();
    passAlmGroup.addOption(Option.builder(PASSWORD_ALM_OPTION).longOpt(PASSWORD_ALM_OPTION_LONG)
            .desc("Password for ALM user to use for retrieving test results").hasArg().argName("PASSWORD")
            .build());//w w  w .  jav  a  2 s.  co  m
    passAlmGroup.addOption(Option.builder(PASSWORD_ALM_FILE_OPTION).longOpt(PASSWORD_ALM_FILE_OPTION_LONG)
            .desc("Location of file with password for ALM user").hasArg().argName("FILE").build());
    options.addOptionGroup(passAlmGroup);

    OptionGroup passOctaneGroup = new OptionGroup();
    passOctaneGroup.addOption(Option.builder(PASSWORD_OCTANE_OPTION).longOpt(PASSWORD_OCTANE_OPTION_LONG)
            .desc("Password for ALM Octane user").hasArg().argName("PASSWORD").optionalArg(true).build());
    passOctaneGroup.addOption(Option.builder(PASSWORD_OCTANE_FILE_OPTION)
            .longOpt(PASSWORD_OCTANE_FILE_OPTION_LONG)
            .desc("Location of file with password for ALM Octane user").hasArg().argName("FILE").build());
    options.addOptionGroup(passOctaneGroup);

    options.addOption(Option.builder(RUN_FILTER_ID_OPTION).longOpt(RUN_FILTER_ID_OPTION_LONG)
            .desc("Filter the ALM test results to retrieve only test runs with this run ID or higher").hasArg()
            .argName("ID").build());
    options.addOption(Option.builder(RUN_FILTER_DATE_OPTION).longOpt(RUN_FILTER_DATE_OPTION_LONG)
            .desc("Filter the ALM test results to retrieve only test runs from this date or later").hasArg()
            .argName("YYYY-MM-DD").build());

    options.addOption(Option.builder(RUN_FILTER_LIMIT_OPTION).longOpt(RUN_FILTER_LIMIT_OPTION_LONG)
            .desc("Limit number of ALM runs to retrieve ").hasArg().argName("NUMBER").build());

    argsWithSingleOccurrence.addAll(Arrays.asList(OUTPUT_FILE_OPTION, CONFIG_FILE_OPTION, PASSWORD_ALM_OPTION,
            PASSWORD_ALM_FILE_OPTION, PASSWORD_OCTANE_OPTION, PASSWORD_OCTANE_FILE_OPTION, RUN_FILTER_ID_OPTION,
            RUN_FILTER_DATE_OPTION, RUN_FILTER_LIMIT_OPTION));

}

From source file:net.lldp.checksims.ChecksimsCommandLine.java

/**
 * @param anyRequired Whether any arguments are required
 * @return CLI options used in Checksims
 *///from www .j  a v a2  s  . c o m
static Options getOpts(boolean anyRequired) {
    Options opts = new Options();

    Option alg = Option.builder("a").longOpt("algorithm").hasArg().argName("name")
            .desc("algorithm to compare with").build();

    Option token = Option.builder("t").longOpt("token").hasArg().argName("type")
            .desc("tokenization to use for submissions").build();

    Option out = Option.builder("o").longOpt("output").hasArgs().argName("name1[,name2,...]")
            .valueSeparator(',').desc("output format(s) to use, comma-separated if multiple given").build();

    Option ignoreInvalid = Option.builder().longOpt("ignoreInvalid")
            .desc("Do not show the result of submissions that do not parse correctly").build();

    Option file = Option.builder("f").longOpt("file").hasArg().argName("filename")
            .desc("print output to given file").build();

    Option preprocess = Option.builder("p").longOpt("preprocess").hasArgs().argName("name1[,name2,...]")
            .valueSeparator(',').desc("preprocessor(s) to apply, comma-separated if multiple given").build();

    Option jobs = Option.builder("j").longOpt("jobs").hasArg().argName("num").desc("number of threads to use")
            .build();

    Option glob = Option.builder("g").longOpt("glob").hasArg().argName("matchpattern")
            .desc("match pattern to determine files included in submissions").build();

    OptionGroup verbosity = new OptionGroup();
    Option verbose = new Option("v", "verbose", false, "specify verbose output. conflicts with -vv");
    Option doubleVerbose = new Option("vv", "veryverbose", false,
            "specify very verbose output. conflicts with -v");
    verbosity.addOption(verbose);
    verbosity.addOption(doubleVerbose);

    Option help = new Option("h", "help", false, "show usage information");

    Option empty = new Option("e", "empty", false, "retain empty submissions");

    Option common = Option.builder("c").longOpt("common").hasArg().argName("path")
            .desc("directory containing common code which will be removed from all submissions").build();

    Option recursive = new Option("r", "recursive", false,
            "recursively traverse subdirectories to generate submissions");

    Option version = new Option("version", false, "print version of Checksims");

    Option archiveDir = Option.builder("archive").longOpt("archivedir")
            .desc("archive submissions - compared to main submissions but not each other").argName("path")
            .hasArgs().valueSeparator('*').build();

    Option submissionDir = Option.builder("s").longOpt("submissiondir")
            .desc("directory or directories containing submissions to compare - mandatory!").argName("path")
            .hasArgs().valueSeparator('*').build();

    if (anyRequired) {
        submissionDir.setRequired(true);
    }

    opts.addOption(alg);
    opts.addOption(token);
    opts.addOption(out);
    opts.addOption(file);
    opts.addOption(preprocess);
    opts.addOption(jobs);
    opts.addOption(glob);
    opts.addOptionGroup(verbosity);
    opts.addOption(help);
    opts.addOption(empty);
    opts.addOption(common);
    opts.addOption(recursive);
    opts.addOption(version);
    opts.addOption(archiveDir);
    opts.addOption(submissionDir);
    opts.addOption(ignoreInvalid);

    return opts;
}

From source file:at.newmedialab.ldpath.backend.linkeddata.LDQuery.java

private static Options buildOptions() {
    Options result = new Options();

    OptionGroup query = new OptionGroup();
    Option path = OptionBuilder.withArgName("path").hasArg()
            .withDescription("LD Path to evaluate on the file starting from the context").create("path");
    Option program = OptionBuilder.withArgName("file").hasArg()
            .withDescription("LD Path program to evaluate on the file starting from the context")
            .create("program");
    query.addOption(path);//from w ww  . j a v a  2  s .c o m
    query.addOption(program);
    query.setRequired(true);
    result.addOptionGroup(query);

    Option context = OptionBuilder.withArgName("uri").hasArg()
            .withDescription("URI of the context node to start from").create("context");
    context.setRequired(true);
    result.addOption(context);

    Option loglevel = OptionBuilder.withArgName("level").hasArg()
            .withDescription("set the log level; default is 'warn'").create("loglevel");
    result.addOption(loglevel);

    Option store = OptionBuilder.withArgName("dir").hasArg()
            .withDescription("cache the retrieved data in this directory").create("store");
    result.addOption(store);

    return result;
}

From source file:edu.psu.cse.siis.coal.CommandLineParser.java

/**
 * Populates the default command line arguments that are common to all analyses.
 * //from   ww  w .j a v a  2  s .  c o  m
 * @param options The command line options object that should be modified.
 */
private void parseDefaultCommandLineArguments(Options options) {
    OptionGroup modelGroup = new OptionGroup();
    modelGroup.addOption(Option.builder("model").desc("Path to the model directory.").hasArg()
            .argName("model directory").build());
    modelGroup.addOption(Option.builder("cmodel").desc("Path to the compiled model.").hasArg()
            .argName("compiled model").build());
    modelGroup.setRequired(false);

    options.addOptionGroup(modelGroup);

    options.addOption(Option.builder("cp").desc("The classpath for the analysis.").hasArg().argName("classpath")
            .required().longOpt("classpath").build());
    options.addOption(Option.builder("in").desc("The input code for the analysis.").hasArg().argName("input")
            .required().longOpt("input").build());
    options.addOption(Option.builder("out").desc("The output directory or file.").hasArg().argName("output")
            .longOpt("output").build());
    options.addOption(
            Option.builder("traversemodeled").desc("Propagate through modeled classes.").hasArg(false).build());
    options.addOption("modeledtypesonly", false, "Only infer modeled types.");
    options.addOption(Option.builder("threadcount").desc("The maximum number of threads that should be used.")
            .hasArg().argName("thread count").type(Number.class).build());
}

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();//from www .ja  va2 s .c  om

    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:com.continuent.tungsten.common.security.PasswordManagerCtrl.java

/**
 * Setup command line options/*w w  w . j  a  va 2s .  c  o m*/
 */
@SuppressWarnings("static-access")
private void setupCommandLine() {
    // --- Options on the command line ---
    Option help = OptionBuilder.withLongOpt(HELP).withDescription("Displays this message").create(_HELP);
    Option file = OptionBuilder.withLongOpt(FILE).withArgName("filename").hasArgs()
            .withDescription("Location of the " + SecurityConf.SECURITY_PROPERTIES_FILE_NAME + " file")
            .create(_FILE);

    // Mutually excluding options
    OptionGroup optionGroup = new OptionGroup();
    authenticate = OptionBuilder.withLongOpt(AUTHENTICATE).hasArgs(2).withArgName("username> <password")
            .withDescription("Authenticates a user with given password").create(_AUTHENTICATE);
    create = OptionBuilder.withLongOpt(CREATE).hasArgs(2).withArgName("username> <password")
            .withDescription("Creates or Updates a user").create(_CREATE);
    Option delete = OptionBuilder.withLongOpt(DELETE).withArgName("username").hasArgs()
            .withDescription("Deletes a user").create(_DELETE);

    optionGroup.addOption(authenticate);
    optionGroup.addOption(create);
    optionGroup.addOption(delete);
    optionGroup.setRequired(true); // At least 1 command required

    Option targetApplication = OptionBuilder.withLongOpt(TARGET_APPLICATION).withArgName("target").hasArgs()
            .withDescription("Target application: " + getListOfClientApplicationType())
            .create(_TARGET_APPLICATION);

    // --- Options replacing parameters from security.properties ---
    Option encryptedPassword = OptionBuilder.withLongOpt(ENCRYPTED_PASSWORD).withArgName("encrypt password")
            .withDescription("Encrypts the password").create(_ENCRYPTED_PASSWORD);
    Option truststoreLocation = OptionBuilder.withLongOpt(TRUSTSTORE_LOCATION).withArgName("filename").hasArg()
            .withDescription("Location of the tuststore file").create(_TRUSTSTORE_LOCATION);
    Option truststorePassword = OptionBuilder.withLongOpt(TRUSTSTORE_PASSWORD).withArgName("password").hasArg()
            .withDescription("Password for the truststore file").create(_TRUSTSTORE_PASSWORD);
    Option keystoreLocation = OptionBuilder.withLongOpt(KEYSTORE_LOCATION).withArgName("filename").hasArg()
            .withDescription("Location of the keystore file").create(_KEYSTORE_LOCATION);
    Option keystorePassword = OptionBuilder.withLongOpt(KEYSTORE_PASSWORD).withArgName("password").hasArg()
            .withDescription("Password for the keystore file").create(_KEYSTORE_PASSWORD);
    Option passwordFileLocation = OptionBuilder.withLongOpt(PASSWORD_FILE_LOCATION).withArgName("filename")
            .hasArg().withDescription("Location of the password file").create(_PASSWORD_FILE_LOCATION);

    // --- Add options to the list ---
    // --- Help
    this.helpOptions.addOption(help);

    // --- Program command line options
    this.options.addOptionGroup(optionGroup);
    this.options.addOption(file);
    this.options.addOption(help);
    this.options.addOption(encryptedPassword);
    this.options.addOption(truststoreLocation);
    this.options.addOption(truststorePassword);
    this.options.addOption(keystoreLocation);
    this.options.addOption(keystorePassword);
    this.options.addOption(passwordFileLocation);

    this.options.addOption(targetApplication);
}

From source file:com.archivas.clienttools.arcmover.cli.ArcProfileMgr.java

@SuppressWarnings({ "static-access" })
public Options getOptions() {
    if (cliOptions == null) {
        Options options = new Options();

        OptionGroup operations = new OptionGroup();

        // *** Adding a new option needs to be added to the cliOrder list
        operations.addOption(OptionBuilder.withDescription("Displays this help text (the default behavior).")
                .withLongOpt("help").create("h"));

        operations.addOption(OptionBuilder.hasOptionalArg().withArgName("profile_name").withDescription(
                "Lists information about the specified namespace profile.  If <profile_name> is omitted, lists information about all namespace profiles.")
                .withLongOpt("list").create("l"));
        operations.addOption(OptionBuilder.hasArg().withArgName("profile_name")
                .withDescription("Deletes the specified namespace profile.").withLongOpt("delete").create("d"));
        operations.addOption(OptionBuilder.hasArg().withArgName("profile_name")
                .withDescription("Creates a namespace profile with the specified name.").withLongOpt("create")
                .create("c"));

        options.addOptionGroup(operations);

        // List the valid profile types dynamically
        String profileTypesToString = "Type of namespace for which you are creating the namespace profile: ";
        for (ProfileType type : ProfileType.values()) {
            if (type != ProfileType.FILESYSTEM) { // Filesystem is already createdcd
                profileTypesToString += (type.toString() + " | ");
            }// ww w . j a v a2s  .co m
        }
        profileTypesToString = profileTypesToString.substring(0, profileTypesToString.length() - 3);

        options.addOption(OptionBuilder.withArgName("profile_type").hasArg()
                .withDescription(profileTypesToString).withLongOpt("type").create());
        options.addOption(OptionBuilder.withArgName("tenant_name").hasArg().withDescription(
                "Name of the tenant that owns the namespace for which you are creating the namespace profile.")
                .withLongOpt("tenant").create());
        options.addOption(OptionBuilder.withArgName("namespace_name").hasArg()
                .withDescription("Name of the namespace for which you are creating the namespace profile.")
                .withLongOpt("namespace").create());
        options.addOption(OptionBuilder.withArgName("username").hasArg()
                .withDescription("Username of the data access account to use for namespace access.")
                .withLongOpt("username").create());
        options.addOption(OptionBuilder.withArgName("password").hasArg()
                .withDescription("Password of the data access account to use for namespace access.")
                .withLongOpt("password").create());
        options.addOption(OptionBuilder.withArgName("hostname").hasArg()
                .withDescription("The fully qualified domain name of the HCP system.").withLongOpt("hostname")
                .create());
        options.addOption(
                OptionBuilder.withDescription("Tells HCP-DM to use SSL when communicating with the HCP system.")
                        .withLongOpt("ssl").create());
        options.addOption(OptionBuilder.withDescription(
                "Tells HCP-DM to check whether custom metadata XML is well-formed prior to communicating with the HCP system.")
                .withLongOpt("check-cm").create());
        options.addOption(OptionBuilder
                .withDescription("Log into namespace anonymously.  Only valid with HCP 5.0 or later profile.")
                .withLongOpt("anon").create());
        options.addOption(OptionBuilder.withDescription(
                "Does not test if the namespace configuration provided can access HCP while creating the profile.")
                .withLongOpt("notest").create());
        options.addOption(OptionBuilder.withArgName("address1[,address2]...").hasArg().withDescription(
                "Comma-separated list of one or more IP addresses to use to connect to the HCP system.  If omitted, HCP-DM uses the hostname.")
                .withLongOpt("ips").create());
        if (ALLOW_PORT) {
            options.addOption(OptionBuilder.withArgName("port").hasArg()
                    .withDescription("Port to connect to HCP on").withLongOpt("port").create());
        }

        cliOptions = options;
    }
    return cliOptions;
}

From source file:com.opengamma.integration.tool.portfolio.PortfolioDeleteTool.java

@Override
protected Options createOptions(boolean contextProvided) {

    Options options = super.createOptions(contextProvided);

    Option portfolioNamesOption = new Option(PORTFOLIO_NAMES_OPT, "name", true,
            "Regular expression to match portfolio names");
    //    options.addOption(portfolioNamesOption);

    Option deletePortfolioIdsOption = new Option(PORTFOLIO_IDS_OPT, "portfolioid", true,
            "Portfolio IDs to match");
    //    options.addOption(deletePortfolioIdsOption);

    OptionGroup group = new OptionGroup();
    group.addOption(deletePortfolioIdsOption);
    group.addOption(portfolioNamesOption);
    group.setRequired(true);/*from   w ww.ja v a 2 s  . c om*/

    options.addOptionGroup(group);

    Option deletePositionsOption = new Option(DELETE_POSITIONS_OPT, "delpositions", false,
            "Match/delete positions referenced in matching portfolios");
    options.addOption(deletePositionsOption);

    Option deleteSecuritiesOption = new Option(DELETE_SECURITIES_OPT, "delsecurities", false,
            "Match/delete securities referenced in matching portfolios");
    options.addOption(deleteSecuritiesOption);

    Option deletePortfoliosOption = new Option(DELETE_PORTFOLIOS_OPT, "delportfolios", false,
            "Actually delete matching portfolios");
    options.addOption(deletePortfoliosOption);

    Option writeOption = new Option(WRITE_OPT, "write", false, "Actually persist the deletions");
    options.addOption(writeOption);

    Option verboseOption = new Option(VERBOSE_OPT, "verbose", false,
            "Displays progress messages on the terminal");
    options.addOption(verboseOption);

    return options;
}