Package org.apache.commons.cli

Examples of org.apache.commons.cli.Option


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

    options.addOption(new Option(LEXICON_OPT, LEXICON_OPT_LONG, true,
                                 "specify lexicon, which should be used"));

    options.addOption(new Option(GRAMMAR_OPT, GRAMMAR_OPT_LONG, true,
                                 "specify grammar, which should be used"));

    options.addOption(new Option(IN_OPT, IN_OPT_LONG, true, "Input file"));

    options.addOption(new Option(OUT_OPT, OUT_OPT_LONG, true, "Output file"));

    CommandLine line = null;
    try
    {
      line = new PosixParser().parse(options, args);
View Full Code Here


        System.out.println(e1.getMessage());
        showUsage();
        System.exit(0);
      }*/
      Options options = new Options();     
      Option optSysTab = OptionBuilder.withArgName("0|1").hasArg().withDescription("set to 1 if source is the system crontab (with user field)").create("systab");
      Option optSourceFile = OptionBuilder.withArgName("file").hasArgs().isRequired()
          .withDescription("crontab file").create("crontab");
      Option optTargetFile = OptionBuilder.withArgName("file").hasArgs().isRequired()
        .withDescription("xml configuration file").create("target");
      Option optLogLevel = OptionBuilder.withArgName("level").hasArg().withType(new Integer(0))
        .withDescription("loglevel [0=info] [1=debug1]...[9=debug9]").create("v");
      Option optChangeUser = OptionBuilder.withArgName("command").hasArgs()
          .withDescription("change user command for -systab=1. 'su' or 'sudo' or define your own command using $SCHEDULER_CRONTAB_USER.")
          .create("changeuser");
      Option optTimeOut = OptionBuilder.withArgName("seconds").hasArg()
        .withDescription("job timeout (0 for unlimited").create("timeout");
      Option optOldRunTime = new Option("oldRunTime","");
     
      options.addOption(optSysTab);
      options.addOption(optSourceFile);
      options.addOption(optTargetFile);
      options.addOption(optLogLevel);
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

    private Main() {
    }

    private static CommandLine parseArgs(String[] args) throws ParseException {
        Options options = new Options();
        Option opt;

        opt = new Option(APP_PATH, true, "Application Path");
        opt.setRequired(false);
        options.addOption(opt);

        opt = new Option(APP_PORT, true, "Application Port");
        opt.setRequired(false);
        options.addOption(opt);

        return new GnuParser().parse(options, args);
    }
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

    protected void addOptionWithParam(String longOption, String shortOption, String argName, String desc) {
        OptionBuilder optionBuilder = OptionBuilder.hasArg().withArgName(argName);
        optionBuilder = optionBuilder.withLongOpt(longOption);
        optionBuilder = optionBuilder.withDescription(desc);
        Option option = optionBuilder.create(shortOption);
        options.addOption(option);
    }
View Full Code Here

    @Override
    protected void constructCommandLineOptions()
    {
      super.constructCommandLineOptions();

      Option sourcesOption = OptionBuilder.withLongOpt(SOURCES_OPT_NAME)
                                          .hasArg()
                                          .withArgName("sources")
                                          .withDescription("comma-separated list of sources:")
                                          .create(SOURCES_OPT_CHAR);
      Option configRootOption = OptionBuilder.withLongOpt(CONFIG_ROOT_OPT_NAME)
                                             .hasArg()
                                             .withArgName("config_rootdir")
                                             .withDescription("directory with all config files; default: .")
                                             .create();
      Option relaysOption = OptionBuilder.withLongOpt(RELAYS_OPT_NAME)
                                         .hasArg()
                                         .withArgName("relay_list")
                                         .withDescription("semicolon-separated list of server:port")
                                         .create(RELAYS_OPT_CHAR);
      Option modPartOption = OptionBuilder.withLongOpt(MOD_PARTITION_OPT_NAME)
                                          .hasArg()
                                          .withArgName("div:[id1,id2,...]")
                                          .withDescription("returns only events for which hash(key) mod div in {id1, ...}")
                                          .create();
      Option bootstrapOption = OptionBuilder.withLongOpt(BOOTSTRAP_OPT_NAME)
                                            .hasOptionalArg()
                                            .withArgName("[true|false]")
                                            .withDescription("enable/disable bootstrap; Default: disabled")
                                            .create(BOOTSTRAP_OPT_CHAR);
      Option bstserversOption = OptionBuilder.withLongOpt(BOOTSTRAP_SERVERS_OPT_NAME)
                                             .hasArg()
                                             .withArgName("bootstrap_server_list")
                                             .withDescription("semicolon-separated list of server:port")
                                             .create();
      Option consumerClassOption = OptionBuilder.withLongOpt(CONSUMER_CLASS_NAME)
                                              .hasArg()
                                              .withArgName("callback_class")
                                              .withDescription("a name of a class that implements " +
                                                  "the DatabusCombinedConsumer interface and " +
                                                  "a default constructor. Add your jars to the" +
View Full Code Here

  @Override
  protected void constructCommandLineOptions()
  {
    super.constructCommandLineOptions();

    Option printVerbosityOption = OptionBuilder.withLongOpt(PRINT_VERBOSITY_OPT_NAME)
                                          .hasArg()
                                          .withArgName("print_verbosity")
                                          .withDescription("print verbosity: " +
                                              Arrays.toString(PrintVerbosity.values()) +
                                              "; default: " + DEFAULT_PRINT_VERBOSITY)
                                          .create(PRINT_VERBOSITY_OPT_CHAR);
    Option outputFormatOption = OptionBuilder.withLongOpt(OUTPUT_FORMAT_OPT_NAME)
                                             .hasArg()
                                             .withArgName("output_format")
                                             .withDescription("output format: " +
                                             Arrays.toString(OutputFormat.values()) +
                                             "; default: " + DEFAUL_OUTPUT_FORMAT)
                                             .create(OUTPUT_FORMAT_OPT_CHAR);
    Option outputOption = OptionBuilder.withLongOpt(OUTPUT_OPT_NAME)
                                       .hasArg()
                                       .withArgName("output_file")
                                       .withDescription("output file or - for STDOUT")
                                       .create(OUTPUT_OPT_CHAR);
    Option resumeOption = OptionBuilder.withLongOpt(RESUME_OPT_NAME)
                                       .hasArg()
                                       .withArgName("checkpoint_dir")
                                       .withDescription("resumes from a previous checkpoint")
                                       .create();
    Option verboseOption = OptionBuilder.withLongOpt(VERBOSE_OPT_NAME)
                                        .withDescription("verbose logging: INFO or above")
                                        .create(VERBOSE_OPT_CHAR);
    Option eventNumOption = OptionBuilder.withLongOpt(EVENT_NUM_OPT_NAME)
                                           .hasArg()
                                           .withArgName("num")
                                           .withDescription("max number of events to return; default: no limit")
                                           .create(EVENT_NUM_OPT_CHAR);
    Option durationOption = OptionBuilder.withLongOpt(DURATION_OPTION_NAME)
                                         .hasArg()
                                         .withArgName("duration_value")
                                         .withDescription("max consumption duration: value[ns|us|ms|s|min|hr|d]; default: no limit")
                                         .create(DURATION_OPTION_CHAR);
    Option statsOption = OptionBuilder.withLongOpt(STATS_OPT_NAME)
                                      .withDescription("print statistics at the end; Default: off")
                                      .create();
    Option sinceScnOption = OptionBuilder.withLongOpt(SCN_OPT_NAME)
                                         .hasArg()
                                         .withArgName("scn")
                                         .withDescription("starts consumption from the given scn; special values: BOB for current beginning of relay buffer, " +
                                              "EOB for current end of buffer; Default: BOB")
                                         .create();
View Full Code Here

     * Creates the command-line options
     */
    @SuppressWarnings("static-access")
    private void constructCommandLineOptions()
    {
      Option helpOption = OptionBuilder.withLongOpt(HELP_OPT_LONG_NAME)
                .withDescription("Prints command-line options info")
                .create(HELP_OPT_CHAR);

      Option schemaRegistryLocation = OptionBuilder.withLongOpt(SCHEMA_REGISTRY_LOCATION_LONG_STR)
          .withDescription("Absolute path to the Schema Registry directory")
          .hasArg().create(SCHEMA_REGISTRY_LOCATION_OPT_CHAR);

      Option schemaNameOption = OptionBuilder.withLongOpt(SCHEMA_NAME_LONG_STR)
          .withDescription("DB Schema (Database) name in which the tables/views to be databusified is present")
          .hasArg().create(SCHEMA_NAME_OPT_CHAR);

      Option dbUriOption = OptionBuilder.withLongOpt(DB_URI_LONG_STR)
          .withDescription("The URI for Oracle (Format : jdbc:oracle:thin:<user>/<password>@<dbhost>:1521:<SID>) or GG trail file location (Format : gg:///mnt/gg/extract/dbext<num>:x<num>)")
          .hasArg().create(DB_URI_OPT_CHAR);

      Option srcNamesOption = OptionBuilder.withLongOpt(SRC_NAMES_LONG_STR)
                                    .withDescription("Comma seperated list of source names (e.g : com.linkedin.events.liar.jobrelay.LiarJobRelay,com.linkedin.events.liar.memberrelay.LiarMemberRelay)")
                                    .hasArg().create(SRC_NAMES_OPT_CHAR);

      Option outputDirectoryOption = OptionBuilder.withLongOpt(OUTPUT_DIRECTORY_LONG_STR)
          .withDescription("Output Directory to generate the relay configs")
          .hasArg().create(OUTPUT_DIRECTORY_OPT_CHAR);

      _cliOptions.addOption(helpOption);
      _cliOptions.addOption(schemaRegistryLocation);
View Full Code Here

  @Override
  protected void constructCommandLineOptions()
  {
    super.constructCommandLineOptions();

    Option automaticOption =
        OptionBuilder.withLongOpt(AUTOMATIC_OPT_NAME)
                     .withDescription("Answer all questions proved through cli automatically and interactive for the rest of the options.")
                     .create(AUTOMATIC_OPT_CHAR);
    Option dbnameOption =
        OptionBuilder.withLongOpt(DBNAME_OPT_NAME)
                     .hasArg()
                     .withArgName("db_name")
                     .withDescription("The name of database")
                     .create(DBNAME_OPT_CHAR);
    Option dburlOption =
        OptionBuilder.withLongOpt(DBURL_OPT_NAME)
                     .hasArg()
                     .withArgName("url")
                     .withDescription("DB URL to read view/table definitions")
                     .create(DBURL_OPT_CHAR);
    Option fieldsOption =
        OptionBuilder.withLongOpt(FIELDS_OPT_NAME)
                     .hasArg()
                     .withArgName("fields")
                     .withDescription("Comma-separated list of table/view fields to include in the schema")
                     .create(FIELDS_OPT_CHAR);
    Option passwordOption =
        OptionBuilder.withLongOpt(PASSWORD_OPT_NAME)
                     .hasArg()
                     .withArgName("password")
                     .withDescription("DB password")
                     .create(PASSWORD_OPT_CHAR);
    Option pkOption =
        OptionBuilder.withLongOpt(PK_OPT_NAME)
                     .hasArg()
                     .withArgName("keys")
                     .withDescription("Comma-separated list of primary keys of view/table")
                     .create(PK_OPT_CHAR);
    Option tableOption =
        OptionBuilder.withLongOpt(TABLE_OPT_NAME)
                     .hasArg()
                     .withArgName("table_name")
                     .withDescription("The name of the table/view whose schema to generate ")
                     .create(TABLE_OPT_CHAR);
    Option userOption =
        OptionBuilder.withLongOpt(USER_OPT_NAME)
                     .hasArg()
                     .withArgName("user")
                     .withDescription("DB username")
                     .create(USER_OPT_CHAR);
    Option schemaRegPathOption =
        OptionBuilder.withLongOpt(SCHEMA_REGISTRY_PATH_OPT_NAME)
                     .hasArg()
                     .withArgName("path")
                     .withDescription("The path where to checkout the schema registry")
                     .create(SCHEMA_REGISTRY_PATH_OPT_CHAR);

    Option numberOverrideOption =
        OptionBuilder.withLongOpt(NUMBEROVERRIDE_OPT_NAME)
            .hasArg()
            .withArgName("path")
            .withDescription("Override number fields datatype with FLOAT, LONG, INTEGER, DOUBLE. Input as, DB_FIELD_NAME1=FLOAT,DB_FIELD_NAME2=DOUBLE")
            .create(NUMBEROVERRIDE_OPT_CHAR);
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.