Esempio n. 1
0
 /** Returns a string to display usage. */
 public String getUsage() {
   StringBuffer usage = new StringBuffer("");
   for (Option o : optsNames.values()) {
     if (o.getHidden()) continue;
     for (int i = 0; i < argMaxLen.size(); ++i) {
       String s = (i < o.getOpts().length) ? o.getOpts()[i] : "";
       int width = argMaxLen.get(i).intValue() + 1;
       String f = String.format(" %-" + width + "s", s);
       usage.append(f).append(" ");
     }
     usage.append(" ").append(o.getDesc()).append("\n");
   }
   return usage.toString();
 }
Esempio n. 2
0
  /** Add an option. */
  public void addOption(Option o) {
    optsNames.put(o.getName(), o);

    int i = 0;
    for (String s : o.getOpts()) {
      updateMaxLength(i, s);
      optsArgs.put(s, o);
      i++;
    }
  }