@SuppressWarnings("static-access")
 private Option createTodayOption() {
   return OptionBuilder.isRequired(false)
       .withDescription("Return if today is a holiday")
       .withLongOpt("today")
       .create("t");
 }
 private static Option createNumMembersOption() {
   OptionBuilder.withLongOpt("members");
   OptionBuilder.withDescription("Number underlyers from index to include");
   OptionBuilder.hasArg();
   OptionBuilder.withArgName("resource");
   OptionBuilder.isRequired();
   return OptionBuilder.create(NUM_INDEX_MEMBERS_OPT);
 }
 private static Option createNumContractsOption() {
   OptionBuilder.withLongOpt("contracts");
   OptionBuilder.withDescription("Number of contracts for each option");
   OptionBuilder.hasArg();
   OptionBuilder.withArgName("resource");
   OptionBuilder.isRequired();
   return OptionBuilder.create(NUM_CONTRACTS_OPT);
 }
 private static Option createOptionDepthOption() {
   OptionBuilder.withLongOpt("depth");
   OptionBuilder.withDescription("Number of options on either side of the strike price");
   OptionBuilder.hasArg();
   OptionBuilder.withArgName("resource");
   OptionBuilder.isRequired();
   return OptionBuilder.create(OPTION_DEPTH_OPT);
 }
 private static Option createPortfolioNameOption() {
   OptionBuilder.withLongOpt("portfolio");
   OptionBuilder.withDescription("The name of the portfolio to create/update");
   OptionBuilder.hasArg();
   OptionBuilder.withArgName("resource");
   OptionBuilder.isRequired();
   return OptionBuilder.create(PORTFOLIO_NAME_OPT);
 }
 @SuppressWarnings("static-access")
 private Option createVerboseOption() {
   return OptionBuilder.isRequired(false)
       .hasArg(false)
       .withDescription("Verbose output")
       .withLongOpt("verbose")
       .create("v");
 }
    @SuppressWarnings("static-access")
    @Override
    public Options getOptions() {
      Options options = super.getOptions();

      options.addOption(OptionBuilder.isRequired().withLongOpt("test").create('t'));

      return options;
    }
 @SuppressWarnings("static-access")
 private Option createCurrencyOption() {
   return OptionBuilder.isRequired(true)
       .hasArg()
       .withArgName("currency code")
       .withDescription("The currency you want to look up")
       .withLongOpt("currency")
       .create("ccy");
 }
 @SuppressWarnings("static-access")
 private Option createDateOption() {
   return OptionBuilder.isRequired(false)
       .hasArg(true)
       .withArgName("date")
       .withDescription("Return if date (YYYYMMDD) is a holiday")
       .withLongOpt("yesterday")
       .create("y");
 }
  /**
   * Build command-line options and descriptions
   *
   * @return command line options
   */
  public static Options buildOptions() {
    Options options = new Options();

    // Build in/output file arguments, which are required, but there is no
    // addOption method that can specify this
    OptionBuilder.isRequired();
    OptionBuilder.hasArgs();
    OptionBuilder.withLongOpt("outputFilename");
    options.addOption(OptionBuilder.create("o"));

    OptionBuilder.isRequired();
    OptionBuilder.hasArgs();
    OptionBuilder.withLongOpt("inputFilename");
    options.addOption(OptionBuilder.create("i"));

    options.addOption("p", "processor", true, "");
    options.addOption("v", "verbose", false, "");
    options.addOption("h", "help", false, "");

    return options;
  }
Esempio n. 11
0
  public void test14786() throws Exception {
    Option o = OptionBuilder.isRequired().withDescription("test").create("test");
    Options opts = new Options();
    opts.addOption(o);
    opts.addOption(o);

    CommandLineParser parser = new GnuParser();

    String[] args = new String[] {"-test"};

    CommandLine line = parser.parse(opts, args);
    assertTrue(line.hasOption("test"));
  }
  static {
    OPTIONS.addOption(
        OptionBuilder.isRequired()
            .withArgName("sourcepath")
            .hasArgs()
            .withDescription(
                "Space-delimited list of directories in which to find resource Java source files\nIf neither -resourcepackages nor -resourcepackages is provided, all classes defined in the directories will be scanned")
            .create("sourcepath"));
    OPTIONS.addOption(
        OptionBuilder.withArgName("name")
            .hasArg()
            .withDescription("Name of the API")
            .create("name"));
    OPTIONS.addOption(
        OptionBuilder.withArgName("outdir")
            .hasArg()
            .withDescription(
                "Directory in which to output the generated IDL files (default=current working dir)")
            .create("outdir"));

    OPTIONS.addOption(
        new Option(
            "split",
            false,
            "DEPRECATED! Splits IDL across multiple files, one per root resource (always true)"));

    final OptionGroup sourceGroup = new OptionGroup();
    final Option sourcePkgs =
        OptionBuilder.withArgName("resourcepackages")
            .hasArgs()
            .withDescription("Space-delimited list of packages to scan for resource classes")
            .create("resourcepackages");
    final Option sourceClasses =
        OptionBuilder.withArgName("resourceclasses")
            .hasArgs()
            .withDescription("space-delimited list of resource classes to scan")
            .create("resourceclasses");
    sourceGroup.addOption(sourcePkgs);
    sourceGroup.addOption(sourceClasses);
    OPTIONS.addOptionGroup(sourceGroup);
  }
Esempio n. 13
0
  /**
   * Parsing command line.
   *
   * @param args
   */
  private void parseCommandLine(String[] args) {
    Options ops = new Options();

    // help
    OptionBuilder.withLongOpt("help");
    OptionBuilder.hasArg(false);
    OptionBuilder.withDescription(rb.getString("OPT_HELP_MSG"));
    ops.addOption(OptionBuilder.create("h"));

    // input file
    OptionBuilder.withLongOpt("input");
    OptionBuilder.hasArg(true);
    OptionBuilder.isRequired(true);
    OptionBuilder.withDescription(rb.getString("OPT_INPUT_MSG"));
    ops.addOption(OptionBuilder.create("i"));

    // input file
    OptionBuilder.withLongOpt("charset");
    OptionBuilder.hasArg(true);
    OptionBuilder.isRequired(false);
    OptionBuilder.withDescription(rb.getString("OPT_CHARSET_MSG"));
    ops.addOption(OptionBuilder.create("ch"));

    OptionBuilder.withDescription(rb.getString("OPT_CSV_MSG"));
    ops.addOption(OptionBuilder.create("csv"));

    OptionBuilder.withDescription(rb.getString("OPT_TABTXT_MSG"));
    ops.addOption(OptionBuilder.create("tab"));

    OptionBuilder.withDescription(rb.getString("OPT_DOUBLE_QUOTES"));
    ops.addOption(OptionBuilder.create("dq"));

    BasicParser parser = new BasicParser();

    try {
      CommandLine cl = parser.parse(ops, args);
      delimiter = ",";
      if (cl.hasOption("tab")) {
        delimiter = "\t";
      } else if (cl.hasOption("csv")) {
        delimiter = ",";
      }

      if (cl.hasOption("dq")) {
        // double quotes
        flgDoubleQuotes = true;
      } else {
        flgDoubleQuotes = false;
      }
      if (cl.hasOption("h")) {
        showHelp(ops);
      }

      charset = "UTF-8";
      if (cl.hasOption("ch")) {
        String val = cl.getOptionValue("ch");
        if (val != null && val.length() > 0) {
          charset = val;
        }
      }

      if (cl.hasOption("i")) {
        String val = cl.getOptionValue("i");
        if (val != null && val.length() > 0) {
          readExcel(val);
        }
      } else {
        showHelp(ops);
      }
    } catch (ParseException e) {
      showHelp(ops);
    }
  }