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

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

Introduction

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

Prototype

public Option(String opt, String longOpt, boolean hasArg, String description) throws IllegalArgumentException 

Source Link

Document

Creates an Option using the specified parameters.

Usage

From source file:jp.ne.sakura.kkkon.StripElfSectionHeader.AppOption.java

public void createOptions() {
    Options opts = new Options();

    {//from   w  w w. j a  va  2  s .c o  m
        Option o = new Option("B", "batch", false, "batch mode. non interactive.");
        opts.addOption(o);
    }
    {
        Option o = new Option(null, "dry-run", false, "dry run");
        opts.addOption(o);
    }
    {
        Option o = new Option(null, "no-keep", false, "no keep backup");
        opts.addOption(o);
    }
    {
        Option o = new Option("o", "output", true, "output file or directory");
        o.setArgName("dest");
        opts.addOption(o);
    }
    opts.addOption("r", "recursive", false, "recursive directory");
    opts.addOption("v", "verbose", false, "verbose display");

    this.options = opts;
}

From source file:com.opengamma.integration.tool.marketdata.MarketDataSnapshotImportTool.java

private static Option createFilenameOption() {
    final Option option = new Option(FILE_NAME_OPTION, "filename", true, "The path to the file to import");
    option.setRequired(true);/*from  w w  w  .  j  av a2s. c  o  m*/
    return option;
}

From source file:com.alibaba.rocketmq.tools.command.message.QueryMsgByIdSubCommand.java

@Override
public Options buildCommandlineOptions(Options options) {
    Option opt = new Option("i", "msgId", true, "Message Id");
    opt.setRequired(true);/*from   w w  w  .j  a v a 2  s  . c  o  m*/
    options.addOption(opt);

    opt = new Option("g", "consumerGroup", true, "consumer group name");
    opt.setRequired(false);
    options.addOption(opt);

    opt = new Option("d", "clientId", true, "The consumer's client id");
    opt.setRequired(false);
    options.addOption(opt);

    return options;
}

From source file:com.yahoo.athenz.example.http.tls.client.HttpTLSClient.java

private static CommandLine parseCommandLine(String[] args) {

    Options options = new Options();

    Option key = new Option("k", "key", true, "private key path");
    key.setRequired(true);/*from w w  w.  ja v a2 s .  c  o  m*/
    options.addOption(key);

    Option cert = new Option("c", "cert", true, "certficate path");
    cert.setRequired(true);
    options.addOption(cert);

    Option trustStore = new Option("t", "trustStorePath", true, "CA TrustStore path");
    trustStore.setRequired(true);
    options.addOption(trustStore);

    Option trustStorePassword = new Option("p", "trustStorePassword", true, "CA TrustStore password");
    trustStorePassword.setRequired(true);
    options.addOption(trustStorePassword);

    Option ztsUrl = new Option("u", "url", true, "HTTP Server url");
    ztsUrl.setRequired(true);
    options.addOption(ztsUrl);

    CommandLineParser parser = new DefaultParser();
    HelpFormatter formatter = new HelpFormatter();
    CommandLine cmd = null;

    try {
        cmd = parser.parse(options, args);
    } catch (ParseException e) {
        System.out.println(e.getMessage());
        formatter.printHelp("zts-tls-client", options);
        System.exit(1);
    }

    return cmd;
}

From source file:com.tc.cli.CommandLineBuilder.java

public void addOption(String opt, String longOpt, boolean hasArg, String description, Class<?> type,
        boolean isRequired) {
    Option option = new Option(opt, longOpt, hasArg, description);
    option.setType(type);//w ww  .  j a v  a 2 s  . co  m
    option.setRequired(isRequired);
    options.addOption(option);
}

From source file:com.alibaba.rocketmq.tools.command.message.PrintMessageByQueueCommand.java

@Override
public Options buildCommandlineOptions(Options options) {
    Option opt = new Option("t", "topic", true, "topic name");
    opt.setRequired(true);/*from   w w  w. j  a  va2s  . co m*/
    options.addOption(opt);

    opt = new Option("a", "brokerName ", true, "broker name");
    opt.setRequired(true);
    options.addOption(opt);

    opt = new Option("i", "queueId ", true, "queue id");
    opt.setRequired(true);
    options.addOption(opt);

    opt = new Option("c", "charsetName ", true, "CharsetName(eg: UTF-8,GBK)");
    opt.setRequired(false);
    options.addOption(opt);

    opt = new Option("s", "subExpression ", true, "Subscribe Expression(eg: TagA || TagB)");
    opt.setRequired(false);
    options.addOption(opt);

    opt = new Option("b", "beginTimestamp ", true,
            "Begin timestamp[currentTimeMillis|yyyy-MM-dd#HH:mm:ss:SSS]");
    opt.setRequired(false);
    options.addOption(opt);

    opt = new Option("e", "endTimestamp ", true, "End timestamp[currentTimeMillis|yyyy-MM-dd#HH:mm:ss:SSS]");
    opt.setRequired(false);
    options.addOption(opt);

    opt = new Option("p", "print msg", true, "print msg. eg: true | false(default)");
    opt.setRequired(false);
    options.addOption(opt);

    opt = new Option("d", "printBody ", true, "print body. eg: true | false(default)");
    opt.setRequired(false);
    options.addOption(opt);

    opt = new Option("f", "calculate", true, "calculate by tag. eg: true | false(default)");
    opt.setRequired(false);
    options.addOption(opt);

    return options;
}

From source file:de.tudarmstadt.lt.lm.app.NgramProbs.java

/**
 * //w w w  . j a v a  2s  .  c  o  m
 */
@SuppressWarnings("static-access")
public NgramProbs(String args[]) {
    Options opts = new Options();

    opts.addOption(new Option("?", "help", false, "display this message"));
    opts.addOption(OptionBuilder.withLongOpt("port").withArgName("port-number").hasArg()
            .withDescription(
                    String.format("Specifies the port on which the rmi registry listens (default: %d).",
                            Registry.REGISTRY_PORT))
            .create("p"));
    opts.addOption(OptionBuilder.withLongOpt("host").withArgName("hostname").hasArg()
            .withDescription("Specifies the hostname on which the rmi registry listens (default: localhost).")
            .create("h"));
    opts.addOption(OptionBuilder.withLongOpt("file").withArgName("name").hasArg().withDescription(
            "Specify the file or directory that contains '.txt' with one ngram per line. Specify '-' to pipe from stdin. (default: '-').")
            .create("f"));
    opts.addOption(OptionBuilder.withLongOpt("out").withArgName("name").hasArg()
            .withDescription("Specify the output file. Specify '-' to use stdout. (default: '-').")
            .create("o"));
    opts.addOption(OptionBuilder.withLongOpt("name").withArgName("identifier").isRequired().hasArg()
            .withDescription("Specify the name of the language model provider that you want to connect to.")
            .create("i"));

    try {
        CommandLine cmd = new ExtendedGnuParser(true).parse(opts, args);
        if (cmd.hasOption("help"))
            CliUtils.print_usage_quit(System.err, StartLM.class.getSimpleName(), opts, USAGE_HEADER, null, 0);

        _host = cmd.getOptionValue("host", "localhost");
        _rmiport = Integer.parseInt(cmd.getOptionValue("port", String.valueOf(Registry.REGISTRY_PORT)));
        _file = cmd.getOptionValue("file", "-");
        _out = cmd.getOptionValue("out", "-");
        _name = cmd.getOptionValue("name");
        _host = cmd.getOptionValue("host", "localhost");

    } catch (Exception e) {
        LOG.error("{}: {}- {}", _rmi_string, e.getClass().getSimpleName(), e.getMessage());
        CliUtils.print_usage_quit(System.err, StartLM.class.getSimpleName(), opts, USAGE_HEADER,
                String.format("%s: %s%n", e.getClass().getSimpleName(), e.getMessage()), 1);
    }
    _rmi_string = String.format("rmi://%s:%d/%s", _host, _rmiport, _name);
}

From source file:is.landsbokasafn.deduplicator.indexer.CommandLineParser.java

/**
 * Constructor./*from   w w  w .  j a  va 2  s  .  com*/
 *
 * @param args Command-line arguments to process.
 * @param out PrintStream to write on.
 *
 * @throws ParseException Failed parse of command line.
 */
public CommandLineParser(String[] args, PrintWriter out) throws ParseException {
    super();

    this.out = out;

    this.options = new Options();
    this.options.addOption(new Option("h", "help", false, "Prints this message and exits."));

    Option opt = new Option("u", "no-url-index", false,
            "Do not index the URLs. Index will only be searchable by digest. "
                    + "Choosing this also sets --no-canonicalized.");
    this.options.addOption(opt);

    this.options.addOption(new Option("s", "no-canonicalized", false,
            "Do not add a canonicalized version of the URL to the index."));

    this.options.addOption(
            new Option("e", "etag", false, "Include etags in the index (if available in the source)."));

    opt = new Option("m", "mime", true,
            "A filter on what mime types are added into the index " + "(blacklist). Default: ^text/.*");
    opt.setArgName("reg.expr.");
    this.options.addOption(opt);

    this.options.addOption(
            new Option("w", "whitelist", false, "Make the --mime filter a whitelist instead of blacklist."));

    this.options.addOption(
            new Option("v", "verbose", false, "Make the program print progress info to standard out."));

    opt = new Option("i", "iterator", true,
            "An iterator suitable for the source data (default iterator " + "works WARC files).");
    opt.setArgName("classname");
    this.options.addOption(opt);

    this.options.addOption(new Option("a", "add", false, "Add source data to existing index."));

    PosixParser parser = new PosixParser();
    try {
        this.commandLine = parser.parse(this.options, args, false);
    } catch (UnrecognizedOptionException e) {
        usage(e.getMessage(), 1);
    }
}

From source file:com.alibaba.rocketmq.tools.command.consumer.ConsumerSubCommand.java

@Override
public Options buildCommandlineOptions(Options options) {
    Option opt = new Option("g", "consumerGroup", true, "consumer group name");
    opt.setRequired(true);//from   ww  w .  j  a  v a 2 s .  c om
    options.addOption(opt);

    opt = new Option("s", "jstack", false, "Run jstack command in the consumer progress");
    opt.setRequired(false);
    options.addOption(opt);

    return options;
}

From source file:com.yahoo.athenz.example.zms.tls.client.ZMSTLSClient.java

private static CommandLine parseCommandLine(String[] args) {

    Options options = new Options();

    Option resource = new Option("r", "resource", true, "resource value");
    resource.setRequired(true);/*from  w w  w. j a  va2 s.  c  o  m*/
    options.addOption(resource);

    Option action = new Option("a", "action", true, "action");
    action.setRequired(true);
    options.addOption(action);

    Option principal = new Option("u", "principal", true, "principal to check for");
    principal.setRequired(true);
    options.addOption(principal);

    Option key = new Option("k", "key", true, "private key path");
    key.setRequired(true);
    options.addOption(key);

    Option cert = new Option("c", "cert", true, "certficate path");
    cert.setRequired(true);
    options.addOption(cert);

    Option trustStore = new Option("t", "trustStorePath", true, "CA TrustStore path");
    trustStore.setRequired(true);
    options.addOption(trustStore);

    Option trustStorePassword = new Option("p", "trustStorePassword", true, "CA TrustStore password");
    trustStorePassword.setRequired(true);
    options.addOption(trustStorePassword);

    Option zmsUrl = new Option("z", "zmsurl", true, "ZMS Server url");
    zmsUrl.setRequired(true);
    options.addOption(zmsUrl);

    CommandLineParser parser = new DefaultParser();
    HelpFormatter formatter = new HelpFormatter();
    CommandLine cmd = null;

    try {
        cmd = parser.parse(options, args);
    } catch (ParseException e) {
        System.out.println(e.getMessage());
        formatter.printHelp("zms-tls-client", options);
        System.exit(1);
    }

    return cmd;
}