Package org.apache.groovy.groovysh
Class GroovyshOptions.Builder
java.lang.Object
org.apache.groovy.groovysh.GroovyshOptions.Builder
- Enclosing class:
- GroovyshOptions
Builder for
GroovyshOptions.- Since:
- 7.0.0
-
Method Summary
Modifier and TypeMethodDescriptionAdds a single binding variable.Replaces the binding variables that will be installed on the engine.build()Builds an immutable options object.compilerConfiguration(CompilerConfiguration compilerConfiguration) Sets the compiler configuration used when noengine(GroovyEngine)is supplied.engine(GroovyEngine engine) Supplies a pre-built engine.errorHandler(GroovyshOptions.ErrorHandler errorHandler) Sets the error handler.Appends command groups.groups(org.jline.shell.CommandGroup... groups) Appends command groups.historyFile(Path historyFile) Sets the history file.onReaderReady(BiConsumer<org.jline.reader.LineReader, org.apache.groovy.groovysh.jline.GroovySystemRegistry> onReaderReady) Registers a callback invoked once the reader and the command registry are both wired, immediately before the REPL starts.onReaderReady(Consumer<org.jline.reader.LineReader> onReaderReady) Registers a callback invoked once the reader is wired, immediately before the REPL starts.Sets a fixed prompt.Sets the prompt supplier, called once per REPL iteration.resultHandler(GroovyshOptions.ResultHandler resultHandler) Sets the result handler.rightPrompt(String rightPrompt) Sets a fixed right-hand prompt.rightPrompt(Supplier<String> rightPrompt) Sets the right-hand prompt supplier.showBanner(boolean showBanner) Sets whether the groovysh banner is printed.terminal(org.jline.terminal.Terminal terminal) Supplies a terminal instead of lettingMainbuild one from CLI flags.
-
Method Details
-
compilerConfiguration
Sets the compiler configuration used when noengine(GroovyEngine)is supplied.- Parameters:
compilerConfiguration- the configuration, ornullfor the default- Returns:
- this builder
-
engine
Supplies a pre-built engine. When set,compilerConfiguration(CompilerConfiguration)is not used to construct a second engine.- Parameters:
engine- the engine- Returns:
- this builder
-
bindings
Replaces the binding variables that will be installed on the engine.- Parameters:
bindings- variables to install;nullis treated as empty- Returns:
- this builder
-
binding
Adds a single binding variable.- Parameters:
name- variable name, must not benullvalue- variable value- Returns:
- this builder
-
groups
Appends command groups. MirrorsShellBuilder.groups(CommandGroup...).- Parameters:
groups- groups to append;nullentries are rejected- Returns:
- this builder
-
groups
Appends command groups.- Parameters:
groups- groups to append;nullis ignored- Returns:
- this builder
-
prompt
Sets a fixed prompt. MirrorsShellBuilder.prompt(String).- Parameters:
prompt- the prompt text, ornullfor"groovy> "- Returns:
- this builder
-
prompt
Sets the prompt supplier, called once per REPL iteration. MirrorsShellBuilder.prompt(Supplier).- Parameters:
prompt- the supplier, ornullfor"groovy> "- Returns:
- this builder
-
rightPrompt
Sets a fixed right-hand prompt. MirrorsShellBuilder.rightPrompt(String).- Parameters:
rightPrompt- the prompt text, ornullfor none- Returns:
- this builder
-
rightPrompt
Sets the right-hand prompt supplier. MirrorsShellBuilder.rightPrompt(Supplier).- Parameters:
rightPrompt- the supplier, ornullfor none- Returns:
- this builder
-
resultHandler
Sets the result handler.- Parameters:
resultHandler- the handler, ornullfor the default printer- Returns:
- this builder
-
errorHandler
Sets the error handler.- Parameters:
errorHandler- the handler, ornullfor groovysh's own trace- Returns:
- this builder
-
showBanner
Sets whether the groovysh banner is printed.- Parameters:
showBanner-falseto suppress the banner- Returns:
- this builder
-
terminal
Supplies a terminal instead of lettingMainbuild one from CLI flags. MirrorsShellBuilder.terminal(Terminal).- Parameters:
terminal- the terminal, ornullto build the default- Returns:
- this builder
-
historyFile
Sets the history file. MirrorsShellBuilder.historyFile(Path).- Parameters:
historyFile- the file, ornullfor groovysh's own- Returns:
- this builder
-
onReaderReady
Registers a callback invoked once the reader is wired, immediately before the REPL starts. MirrorsShellBuilder.onReaderReady(Consumer).- Parameters:
onReaderReady- the callback, ornullfor none- Returns:
- this builder
-
onReaderReady
public GroovyshOptions.Builder onReaderReady(BiConsumer<org.jline.reader.LineReader, org.apache.groovy.groovysh.jline.GroovySystemRegistry> onReaderReady) Registers a callback invoked once the reader and the command registry are both wired, immediately before the REPL starts. MirrorsShellBuilder.onReaderReady(BiConsumer).This is the hook for completion. groovysh has already assigned
reader.setCompleter(registry.completer())by the time the callback runs, so an embedder contributing its own completion wraps that, for examplereader.setCompleter(new AggregateCompleter(registry.completer(), mine)). Candidates from anAggregateCompleterare merged, so a completer added this way supplements groovysh's rather than replacing it; assign a completer of your own to replace it outright.- Parameters:
onReaderReady- the callback, ornullfor none- Returns:
- this builder
-
build
Builds an immutable options object.- Returns:
- the options
-