Beispiel #1
0
  /**
   * @param optionName
   * @return
   */
  public OptionItem getOption(String optionName) {
    for (OptionItem eachOption : optionItemList) {
      Option opt = eachOption.getOption();
      if (optionName.equals(opt.symbol())) return eachOption;

      String longName = opt.longName();
      if (longName != null && optionName.equals(longName)) return eachOption;
    }

    return null;
  }
Beispiel #2
0
  protected static String optionDescription(OptionItem optionItem) {
    StringBuilder line = new StringBuilder();
    Option opt = optionItem.getOption();
    if (optionItem.hasSymbol()) {
      line.append(String.format("-%s", opt.symbol()));
      if (optionItem.hasLongName()) {
        line.append(String.format(", --%s", opt.longName()));

        if (optionItem.needsArgument()) line.append(String.format("=%s", opt.varName()));
      } else {
        if (optionItem.needsArgument()) line.append(String.format(" ", opt.varName()));
      }
    } else if (optionItem.hasLongName()) {
      line.append(String.format("    --%s", opt.longName()));
      if (optionItem.needsArgument()) line.append(String.format("=%s", opt.varName()));
    } else {
      throw new XerialError(XerialErrorCode.NO_OPTION, optionItem.toString());
    }

    return line.toString();
  }