Class ConsoleDispatcherBuilder


  • public class ConsoleDispatcherBuilder
    extends java.lang.Object
    Factory that creates a CommandDispatcher backed by the legacy console infrastructure (SystemRegistryImpl, Builtins, and optionally ConsoleEngineImpl).

    This builder replaces the complex wiring that was previously in the old Shell class. It creates a dispatcher that uses the old console API internally while presenting the new CommandDispatcher interface.

    Example:

     CommandDispatcher dispatcher = ConsoleDispatcherBuilder.builder()
         .terminal(terminal)
         .parser(parser)
         .builtins(builtins)
         .commands(myRegistry)
         .build();
    
     Shell shell = Shell.builder()
         .dispatcher(dispatcher)
         .build();
     shell.run();
     
    Since:
    4.0
    See Also:
    Shell
    • Method Detail

      • terminal

        public ConsoleDispatcherBuilder terminal​(org.jline.terminal.Terminal terminal)
        Sets the terminal.
        Parameters:
        terminal - the terminal
        Returns:
        this builder
      • parser

        public ConsoleDispatcherBuilder parser​(org.jline.reader.Parser parser)
        Sets the parser.
        Parameters:
        parser - the parser
        Returns:
        this builder
      • builtins

        public ConsoleDispatcherBuilder builtins​(Builtins builtins)
        Sets the builtins registry.
        Parameters:
        builtins - the builtins
        Returns:
        this builder
      • groups

        public ConsoleDispatcherBuilder groups​(org.jline.shell.CommandGroup... groups)
        Adds new-style command groups (they will be adapted to CommandRegistry).
        Parameters:
        groups - the command groups
        Returns:
        this builder
      • workDir

        public ConsoleDispatcherBuilder workDir​(java.util.function.Supplier<java.nio.file.Path> workDir)
        Sets the working directory supplier.
        Parameters:
        workDir - the working directory supplier
        Returns:
        this builder
      • consoleEngine

        public ConsoleDispatcherBuilder consoleEngine​(ConsoleEngine consoleEngine)
        Sets the console engine for scripting support.
        Parameters:
        consoleEngine - the console engine
        Returns:
        this builder
      • scriptEngine

        public ConsoleDispatcherBuilder scriptEngine​(ScriptEngine scriptEngine)
        Sets the script engine.
        Parameters:
        scriptEngine - the script engine
        Returns:
        this builder
      • initScript

        public ConsoleDispatcherBuilder initScript​(java.io.File initScript)
        Sets the initialization script.
        Parameters:
        initScript - the init script
        Returns:
        this builder
      • build

        public org.jline.shell.CommandDispatcher build()
        Builds the dispatcher.

        Creates a SystemRegistryImpl backed dispatcher that wraps the old console API with the new CommandDispatcher interface.

        Returns:
        the command dispatcher