Search in sources :

Example 81 with Option

use of org.apache.commons.cli.Option in project hbase by apache.

the class DataBlockEncodingTool method printUsage.

private static void printUsage(Options options) {
    System.err.println("Usage:");
    System.err.println(String.format("./hbase %s <options>", DataBlockEncodingTool.class.getName()));
    System.err.println("Options:");
    for (Object it : options.getOptions()) {
        Option opt = (Option) it;
        if (opt.hasArg()) {
            System.err.println(String.format("-%s %s: %s", opt.getOpt(), opt.getArgName(), opt.getDescription()));
        } else {
            System.err.println(String.format("-%s: %s", opt.getOpt(), opt.getDescription()));
        }
    }
}
Also used : Option(org.apache.commons.cli.Option)

Example 82 with Option

use of org.apache.commons.cli.Option in project hbase by apache.

the class HFilePrettyPrinter method init.

private void init() {
    options.addOption("v", "verbose", false, "Verbose output; emits file and meta data delimiters");
    options.addOption("p", "printkv", false, "Print key/value pairs");
    options.addOption("e", "printkey", false, "Print keys");
    options.addOption("m", "printmeta", false, "Print meta data of file");
    options.addOption("b", "printblocks", false, "Print block index meta data");
    options.addOption("h", "printblockheaders", false, "Print block headers for each block.");
    options.addOption("k", "checkrow", false, "Enable row order check; looks for out-of-order keys");
    options.addOption("a", "checkfamily", false, "Enable family check");
    options.addOption("w", "seekToRow", true, "Seek to this row and print all the kvs for this row only");
    options.addOption("s", "stats", false, "Print statistics");
    options.addOption("i", "checkMobIntegrity", false, "Print all cells whose mob files are missing");
    OptionGroup files = new OptionGroup();
    files.addOption(new Option("f", "file", true, "File to scan. Pass full-path; e.g. hdfs://a:9000/hbase/hbase:meta/12/34"));
    files.addOption(new Option("r", "region", true, "Region to scan. Pass region name; e.g. 'hbase:meta,,1'"));
    options.addOptionGroup(files);
}
Also used : OptionGroup(org.apache.commons.cli.OptionGroup) Option(org.apache.commons.cli.Option)

Example 83 with Option

use of org.apache.commons.cli.Option in project hbase by apache.

the class ThriftServer method getOptions.

private static Options getOptions() {
    Options options = new Options();
    options.addOption("b", "bind", true, "Address to bind the Thrift server to. [default: 0.0.0.0]");
    options.addOption("p", "port", true, "Port to bind to [default: " + DEFAULT_LISTEN_PORT + "]");
    options.addOption("f", "framed", false, "Use framed transport");
    options.addOption("c", "compact", false, "Use the compact protocol");
    options.addOption("w", "workers", true, "How many worker threads to use.");
    options.addOption("s", "selectors", true, "How many selector threads to use.");
    options.addOption("q", "callQueueSize", true, "Max size of request queue (unbounded by default)");
    options.addOption("h", "help", false, "Print help information");
    options.addOption(null, "infoport", true, "Port for web UI");
    options.addOption("t", READ_TIMEOUT_OPTION, true, "Amount of time in milliseconds before a server thread will timeout " + "waiting for client to send data on a connected socket. Currently, " + "only applies to TBoundedThreadPoolServer");
    OptionGroup servers = new OptionGroup();
    servers.addOption(new Option("nonblocking", false, "Use the TNonblockingServer. This implies the framed transport."));
    servers.addOption(new Option("hsha", false, "Use the THsHaServer. This implies the framed transport."));
    servers.addOption(new Option("selector", false, "Use the TThreadedSelectorServer. This implies the framed transport."));
    servers.addOption(new Option("threadpool", false, "Use the TThreadPoolServer. This is the default."));
    options.addOptionGroup(servers);
    return options;
}
Also used : Options(org.apache.commons.cli.Options) OptionGroup(org.apache.commons.cli.OptionGroup) Option(org.apache.commons.cli.Option)

Example 84 with Option

use of org.apache.commons.cli.Option in project cassandra by apache.

the class Legacy method printHelpMessage.

public static void printHelpMessage() {
    System.out.println("Usage: ./bin/cassandra-stress legacy [options]\n\nOptions:");
    System.out.println("THIS IS A LEGACY SUPPORT MODE");
    for (Object o : availableOptions.getOptions()) {
        Option option = (Option) o;
        String upperCaseName = option.getLongOpt().toUpperCase();
        System.out.println(String.format("-%s%s, --%s%s%n\t\t%s%n", option.getOpt(), (option.hasArg()) ? " " + upperCaseName : "", option.getLongOpt(), (option.hasArg()) ? "=" + upperCaseName : "", option.getDescription()));
    }
}
Also used : Option(org.apache.commons.cli.Option)

Example 85 with Option

use of org.apache.commons.cli.Option in project hive by apache.

the class HiveSchemaTool method initOptions.

// Create the required command line options
@SuppressWarnings("static-access")
private static void initOptions(Options cmdLineOptions) {
    Option help = new Option("help", "print this message");
    Option upgradeOpt = new Option("upgradeSchema", "Schema upgrade");
    Option upgradeFromOpt = OptionBuilder.withArgName("upgradeFrom").hasArg().withDescription("Schema upgrade from a version").create("upgradeSchemaFrom");
    Option initOpt = new Option("initSchema", "Schema initialization");
    Option initToOpt = OptionBuilder.withArgName("initTo").hasArg().withDescription("Schema initialization to a version").create("initSchemaTo");
    Option infoOpt = new Option("info", "Show config and schema details");
    Option validateOpt = new Option("validate", "Validate the database");
    OptionGroup optGroup = new OptionGroup();
    optGroup.addOption(upgradeOpt).addOption(initOpt).addOption(help).addOption(upgradeFromOpt).addOption(initToOpt).addOption(infoOpt).addOption(validateOpt);
    optGroup.setRequired(true);
    Option userNameOpt = OptionBuilder.withArgName("user").hasArgs().withDescription("Override config file user name").create("userName");
    Option passwdOpt = OptionBuilder.withArgName("password").hasArgs().withDescription("Override config file password").create("passWord");
    Option dbTypeOpt = OptionBuilder.withArgName("databaseType").hasArgs().withDescription("Metastore database type").create("dbType");
    Option dbOpts = OptionBuilder.withArgName("databaseOpts").hasArgs().withDescription("Backend DB specific options").create("dbOpts");
    Option dryRunOpt = new Option("dryRun", "list SQL scripts (no execute)");
    Option verboseOpt = new Option("verbose", "only print SQL statements");
    Option serversOpt = OptionBuilder.withArgName("serverList").hasArgs().withDescription("a comma-separated list of servers used in location validation").create("servers");
    cmdLineOptions.addOption(help);
    cmdLineOptions.addOption(dryRunOpt);
    cmdLineOptions.addOption(userNameOpt);
    cmdLineOptions.addOption(passwdOpt);
    cmdLineOptions.addOption(dbTypeOpt);
    cmdLineOptions.addOption(verboseOpt);
    cmdLineOptions.addOption(dbOpts);
    cmdLineOptions.addOption(serversOpt);
    cmdLineOptions.addOptionGroup(optGroup);
}
Also used : OptionGroup(org.apache.commons.cli.OptionGroup) Option(org.apache.commons.cli.Option)

Aggregations

Option (org.apache.commons.cli.Option)152 Options (org.apache.commons.cli.Options)105 CommandLine (org.apache.commons.cli.CommandLine)53 CommandLineParser (org.apache.commons.cli.CommandLineParser)52 ParseException (org.apache.commons.cli.ParseException)41 GnuParser (org.apache.commons.cli.GnuParser)39 HelpFormatter (org.apache.commons.cli.HelpFormatter)30 File (java.io.File)13 OptionGroup (org.apache.commons.cli.OptionGroup)13 FileInputStream (java.io.FileInputStream)10 IOException (java.io.IOException)10 HashMap (java.util.HashMap)9 DefaultParser (org.apache.commons.cli.DefaultParser)9 Properties (java.util.Properties)8 BasicParser (org.apache.commons.cli.BasicParser)6 ConsoleAppender (org.apache.log4j.ConsoleAppender)6 PatternLayout (org.apache.log4j.PatternLayout)6 ArrayList (java.util.ArrayList)5 PosixParser (org.apache.commons.cli.PosixParser)5 List (java.util.List)3