code: public void pushCommandLine(String commandLine) {
          // Add new history entry to the end.
          history.add(commandLine);
  
          // Maintain max history size.
          if (history.size() > maxHistory) {
              history.remove(0);
          }
  
          // Reset the iteration index.
          resetCurrentIndex();
      }
docs: Adds a new command line to the history buffer. Resets the current history index.
  
  @param commandLine Command line to add to history.