java.lang.Object
org.jline.console.impl.ConsoleDispatcherBuilder
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:
-
Method Summary
Modifier and TypeMethodDescriptionorg.jline.shell.CommandDispatcherbuild()Builds the dispatcher.static ConsoleDispatcherBuilderbuilder()Creates a new builder.Sets the builtins registry.commands(CommandRegistry... registries) Adds old-style command registries.consoleEngine(ConsoleEngine consoleEngine) Sets the console engine for scripting support.groups(org.jline.shell.CommandGroup... groups) Adds new-style command groups (they will be adapted to CommandRegistry).initScript(File initScript) Sets the initialization script.parser(org.jline.reader.Parser parser) Sets the parser.scriptEngine(ScriptEngine scriptEngine) Sets the script engine.terminal(org.jline.terminal.Terminal terminal) Sets the terminal.Sets the working directory supplier.
-
Method Details
-
builder
Creates a new builder.- Returns:
- a new builder
-
terminal
Sets the terminal.- Parameters:
terminal- the terminal- Returns:
- this builder
-
parser
Sets the parser.- Parameters:
parser- the parser- Returns:
- this builder
-
builtins
Sets the builtins registry.- Parameters:
builtins- the builtins- Returns:
- this builder
-
commands
Adds old-style command registries.- Parameters:
registries- the command registries- Returns:
- this builder
-
groups
Adds new-style command groups (they will be adapted to CommandRegistry).- Parameters:
groups- the command groups- Returns:
- this builder
-
workDir
Sets the working directory supplier.- Parameters:
workDir- the working directory supplier- Returns:
- this builder
-
consoleEngine
Sets the console engine for scripting support.- Parameters:
consoleEngine- the console engine- Returns:
- this builder
-
scriptEngine
Sets the script engine.- Parameters:
scriptEngine- the script engine- Returns:
- this builder
-
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
SystemRegistryImplbacked dispatcher that wraps the old console API with the newCommandDispatcherinterface.- Returns:
- the command dispatcher
-