@SuppressWarnings("unchecked")
  void run() throws IOException {
    inConsole = true;
    myCommands = buildMyCommands();
    if (cl.getCommand() == null) {
      System.out.println("Welcome to Hedwig!");
      System.out.println("JLine support is enabled");

      console = new ConsoleReader();
      JLineHedwigCompletor completor = new JLineHedwigCompletor(admin);
      console.addCompletor(completor);

      // load history file
      History history = new History();
      File file =
          new File(
              System.getProperty(
                  "hw.history",
                  new File(System.getProperty("user.home"), HW_HISTORY_FILE).toString()));
      if (LOG.isDebugEnabled()) {
        LOG.debug("History file is " + file.toString());
      }
      history.setHistoryFile(file);
      // set history to console reader
      console.setHistory(history);
      // load history from history file
      history.moveToFirstEntry();

      while (history.next()) {
        String entry = history.current();
        if (!entry.equals("")) {
          addToHistory(commandCount, entry);
        }
        commandCount++;
      }
      System.out.println("JLine history support is enabled");

      String line;
      while ((line = console.readLine(getPrompt())) != null) {
        executeLine(line);
        history.addToHistory(line);
      }
    }

    inConsole = false;
    processCmd(cl);
    try {
      myCommands.get(EXIT).runCmd(new String[0]);
    } catch (Exception e) {
    }
  }