code: public void read(final Connection conn, final Readline readline) {
          // Just call readline and get a callback when line is openBlocking
          Prompt prompt = new Prompt(new TerminalString("[aesh@rules]$ ",
                          new TerminalColor(Color.GREEN, Color.DEFAULT, Color.Intensity.BRIGHT)));
  
          //suspend reader asap since we're creating commands in a new thread
          //this is not needed when running single threaded, eg as examples.Example
         readline.readline(conn, prompt, line -> {
              //we got eof or quit
              if (line == null) {
                  conn.close();
                  return;
              }
  
              //LOGGER.info("got: " + line);
  
              Matcher matcher = splitter.matcher(line);
              if (matcher.find()) {
                  String cmd = matcher.group();
  
                  /*
                  if(cmd.equals("exit")) {
                      conn.write("exiting...\n").close();
                      return;
                  }
                  */
  
                  // Gather args
                  List<String> args = new ArrayList<>();
                  while (matcher.find()) {
                      args.add(matcher.group());
                  }
  
                  try {
                      new Task(conn, readline, Command.valueOf(cmd), args).start();
                      return;
                  } catch (IllegalArgumentException e) {
                      conn.write(line + ": command not found\n");
                  }
              }
              read(conn, readline);
          }, getCompletions());
      }
docs: Use {@link Readline} to openBlocking a user input and then process it
  
  @param conn the tty connection
  @param readline the readline object