Пример #1
0
  /**
   * Parse a command
   *
   * @return the next index to process. i.e., if calling this method processes two commands, then
   *     the return value should be index+2
   */
  protected int parseCommand(String args[], int index, Set<String> source)
      throws UsageError, Main.TerminationException {
    // Find a flag whose id matches args[index] and let it process the
    // arguments.
    for (OptFlag<?> flag : flags) {
      if (flag.ids.contains(args[index])) {
        Arg<?> arg = flag.handle(args, index + 1);
        arguments.add(arg);
        return arg.next();
      }
    }

    if (!args[index].startsWith("-")) {
      index = parseSourceArg(args, index);
    }

    return index;
  }
Пример #2
0
 protected int parseSourceArg(String[] args, int index) {
   Arg<String> src = new Arg<>(index + 1, args[index]);
   arguments.add(src);
   return src.next();
 }