Package org.apache.commons.cli

Examples of org.apache.commons.cli.Option


        Option create() throws IllegalArgumentException
        {
            Preconditions.checkNotNull(shortopt);
           
            Option option = null;
            // create the option
            option = new Option(shortopt, description);

            // set the option properties
            option.setLongOpt(longopt);
            option.setRequired(required);
            option.setOptionalArg(optionalArg);
            option.setArgs(numberOfArgs);
            option.setType(type);
            option.setValueSeparator(valuesep);
            option.setArgName(argName);

            // return the Option instance
            return option;
        }
View Full Code Here


      boolean isZkConfigured = false;

      Options options = new Options();

      Option option = new Option("n", "name", true, "the name of this agent");
      option.setRequired(true);
      options.addOption(option);

      option = new Option("f", "conf-file", true,
          "specify a config file (required if -z missing)");
      option.setRequired(false);
      options.addOption(option);

      option = new Option(null, "no-reload-conf", false,
          "do not reload config file if changed");
      options.addOption(option);

      // Options for Zookeeper
      option = new Option("z", "zkConnString", true,
          "specify the ZooKeeper connection to use (required if -f missing)");
      option.setRequired(false);
      options.addOption(option);

      option = new Option("p", "zkBasePath", true,
          "specify the base path in ZooKeeper for agent configs");
      option.setRequired(false);
      options.addOption(option);

      option = new Option("h", "help", false, "display help text");
      options.addOption(option);

      CommandLineParser parser = new GnuParser();
      CommandLine commandLine = parser.parse(options, args);
View Full Code Here

    protected final void configure() {
        configureOptions();
       
        Options options = new Options();
        for (OptionBuilder builder : builders) {
            Option option = builder.create();
            if (builder.annot != null) {
                bind(String.class)
                    .annotatedWith(builder.annot)
                    .toProvider(new StringOptionProvider(option, builder.defaultValue))
                    .asEagerSingleton();
               
                LOG.info("Binding option to annotation : " + builder.annot.getName());
            }
            else {
                bind(String.class)
                    .annotatedWith(Names.named(option.getOpt()))
                    .toProvider(new StringOptionProvider(option, builder.defaultValue))
                    .asEagerSingleton();
                LOG.info("Binding option to String : " + option.getOpt());
            }
            options.addOption(option);
        }
       
        bind(Options.class).toInstance(options);
View Full Code Here

    }
  }

  public static void main(String[] args) throws Exception {
    Options options = new Options();
    Option opt = new Option("c", true, "checkpoint directory");
    opt.setRequired(true);
    options.addOption(opt);
    opt = new Option("l", true, "comma-separated list of log directories");
    opt.setRequired(true);
    options.addOption(opt);
    options.addOption(opt);
    opt = new Option("t", true, "capacity of the channel");
    opt.setRequired(true);
    options.addOption(opt);
    CommandLineParser parser = new GnuParser();
    CommandLine cli = parser.parse(options, args);
    File checkpointDir = new File(cli.getOptionValue("c"));
    String[] logDirs = cli.getOptionValue("l").split(",");
View Full Code Here

import org.apache.commons.cli.Options;
import org.apache.commons.cli.ParseException;

public class Main {
    private static Options getOptions() {
        Option dir = OptionBuilder.withArgName( "dir" )
            .hasArg()
            .withDescription"give total size of files in given dir" )
            .create( "dir" );
        Option name = OptionBuilder.withArgName( "name" )
            .hasArg()
            .withDescription"give total size of files with given name" )
            .create( "name" );
        Options options = new Options();
View Full Code Here

import org.apache.commons.cli.Options;
import org.apache.commons.cli.ParseException;

public class Main {
    private static Options getOptions() {
        Option dir = OptionBuilder.withArgName("dir")
            .hasArg()
            .withDescription("list files in given dir")
            .create("dir");
        Option name = OptionBuilder.withArgName("name")
            .hasArg()
            .withDescription("list files with given name")
            .create("name");
        Options options = new Options();
View Full Code Here

import org.apache.commons.cli.Options;
import org.apache.commons.cli.ParseException;

public class Main {
    private static Options getOptions() {
        Option dir = OptionBuilder.withArgName( "dir" )
            .hasArg()
            .withDescription"list files in given dir" )
            .create( "dir" );
        Options options = new Options();
View Full Code Here

        .withDescription("group id").create(GROUP_OPTION));
    options.addOption(OptionBuilder.withArgName("string").hasArg()
        .withDescription("access token").create(TOKEN_OPTION));
    options.addOption(OptionBuilder.withArgName("string").hasArg()
        .withDescription("runtag").create(RUNTAG_OPTION));
    options.addOption(new Option(VERBOSE_OPTION, "print out complete document"));

    CommandLine cmdline = null;
    CommandLineParser parser = new GnuParser();
    try {
      cmdline = parser.parse(options, args);
View Full Code Here

        .withDescription("group id").create(GROUP_OPTION));
    options.addOption(OptionBuilder.withArgName("string").hasArg()
        .withDescription("access token").create(TOKEN_OPTION));
    options.addOption(OptionBuilder.withArgName("string").hasArg()
        .withDescription("runtag").create(RUNTAG_OPTION));
    options.addOption(new Option(VERBOSE_OPTION, "print out complete document"));

    CommandLine cmdline = null;
    CommandLineParser parser = new GnuParser();
    try {
      cmdline = parser.parse(options, args);
View Full Code Here

  public static void main(String[] args)
    throws Exception
  {
    Options options = new Options();
    Option option;

    option = new Option("n", "name",  true, "Name");
    option.setRequired(true);
    options.addOption(option);

    option = new Option("c", "channels",  true, "A comma delimited set of channels to join");
    option.setRequired(true);
    options.addOption(option);

    option = new Option("h", "irc-host",  true, "The IRCD host");
    option.setRequired(true);
    options.addOption(option);

    option = new Option("p", "irc-port",  true, "The IRCD port");
    option.setRequired(true);
    options.addOption(option);

    option = new Option("a", "irc-pass",  true, "IRCd Server password");
    option.setRequired(false);
    options.addOption(option);

    option = new Option("g", "graphite-enabled",  false, "Set to true to log stats to graphite");
    options.addOption(option);

    option = new Option("r", "graphite-host",  true, "Graphite server hostname");
    options.addOption(option);

    option = new Option("t", "graphite-port",  true, "Graphite server port");
    options.addOption(option);

    CommandLineParser parser = new PosixParser();
    CommandLine commandLine = null;
    try {
View Full Code Here

TOP

Related Classes of org.apache.commons.cli.Option

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.