Interface ScriptRunner

All Known Implementing Classes:
DefaultScriptRunner
Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface ScriptRunner
Executes a script file line by line through a CommandDispatcher.

A ScriptRunner reads lines from a script file and feeds them to the dispatcher for execution. The exact behavior (comment handling, line continuation, error handling) is determined by the implementation.

Example:

 ScriptRunner runner = (script, session, dispatcher) -> {
     Files.readAllLines(script).forEach(line -> dispatcher.execute(line));
 };
 
Since:
4.0
See Also:
  • Method Details

    • execute

      void execute(Path script, CommandSession session, CommandDispatcher dispatcher) throws Exception
      Executes a script file.
      Parameters:
      script - the path to the script file
      session - the current command session
      dispatcher - the command dispatcher to execute lines through
      Throws:
      Exception - if script execution fails