@Override
  public void shutdown() {
    for (App app : this.appInstances.values()) {
      app.shutdown();
    }

    super.shutdown();
  }
 public TabCompletion tabComplete(String partOfLine, Session session)
     throws ShellException, RemoteException {
   // TODO We can't assume it's an AppShellServer, can we?
   AppCommandParser parser = new AppCommandParser(this, partOfLine);
   App app = parser.app();
   List<String> appCandidates = app.completionCandidates(partOfLine, session);
   appCandidates = quote(appCandidates);
   if (appCandidates.size() == 1) {
     appCandidates.set(0, appCandidates.get(0) + " ");
   }
   int cursor = partOfLine.length() - TextUtil.lastWordOrQuoteOf(partOfLine, true).length();
   return new TabCompletion(appCandidates, cursor);
 }
Exemplo n.º 3
0
  @Override
  public Continuation execute(AppCommandParser parser, Session session, Output out)
      throws Exception {
    if (parser.arguments().size() == 0) {
      boolean list = parser.options().containsKey("l");
      printHelpString(out, getServer(), list);
      return Continuation.INPUT_COMPLETE;
    }

    App app = this.getApp(parser);
    out.println("");
    for (String line : splitLongLine(fixDesciption(app.getDescription()), CONSOLE_WIDTH)) {
      out.println(line);
    }
    println(out, "");
    boolean hasOptions = false;
    for (String option : app.getAvailableOptions()) {
      hasOptions = true;
      String description = fixDesciption(app.getDescription(option));
      String[] descriptionLines = splitLongLine(description, CONSOLE_WIDTH);
      for (int i = 0; i < descriptionLines.length; i++) {
        String line = "";
        if (i == 0) {
          String optionPrefix = option.length() > 1 ? "--" : "-";
          line = optionPrefix + option;
        }
        line += "\t ";
        line += descriptionLines[i];
        println(out, line);
      }
    }
    if (hasOptions) {
      println(out, "");
    }
    return Continuation.INPUT_COMPLETE;
  }
Exemplo n.º 4
0
 @Override
 protected Continuation exec(AppCommandParser parser, Session session, Output out)
     throws Exception {
   return sh.execute(parser, session, out);
 }