@Incubating
public final class GroovyshOptions
extends Object
Configuration for embedding groovysh programmatically via Main.start.
Where a setting has an equivalent on JLine's org.jline.shell.ShellBuilder,
this class deliberately uses the same name and parameter type, so that a future
move of groovysh onto org.jline.shell is re-plumbing rather than a break
in Groovy's API. The Groovy-specific settings — compiler configuration, engine,
bindings, banner, and the result/error handlers a language REPL needs and a
command shell does not — have no such equivalent.
Binding variables stay in getBindings(); they are not mixed with embedding hooks. Construct with builder().
| Modifiers | Name | Description |
|---|---|---|
static class |
GroovyshOptions.Builder |
Builder for GroovyshOptions. |
interface |
GroovyshOptions.ErrorHandler |
Handles an error thrown by the REPL loop. |
interface |
GroovyshOptions.ResultHandler |
Handles a value produced by the REPL loop. |
| Type Params | Return Type | Name and description |
|---|---|---|
|
public static GroovyshOptions.Builder |
builder()Creates a builder for embedding options. |
|
public Map<String, Object> |
getBindings()Binding variables installed on the engine before the REPL starts. |
|
public CompilerConfiguration |
getCompilerConfiguration()Compiler configuration used when this object does not already hold an engine. |
|
public GroovyEngine |
getEngine()Pre-built engine. |
|
public GroovyshOptions.ErrorHandler |
getErrorHandler()Error renderer. |
|
public List<org.jline.shell.CommandGroup> |
getGroups()Command groups contributed by the embedder. |
|
public Path |
getHistoryFile()History file for the session. |
|
public BiConsumer<org.jline.reader.LineReader, GroovySystemRegistry> |
getOnReaderReady()Callback invoked once the reader and the command registry are both wired, immediately before the REPL starts, for settings this class does not model — the secondary prompt pattern, key bindings, reader options, and the completer. |
|
public Supplier<String> |
getPrompt()Prompt supplier invoked on each REPL iteration. |
|
public GroovyshOptions.ResultHandler |
getResultHandler()Result renderer. |
|
public Supplier<String> |
getRightPrompt()Right-hand prompt supplier invoked on each REPL iteration. |
|
public Terminal |
getTerminal()Terminal to use instead of the one Main would build from CLI flags. |
|
public boolean |
isShowBanner()Whether Main should print the groovysh banner (or the quiet version line). |
Creates a builder for embedding options.
Binding variables installed on the engine before the REPL starts.
null Compiler configuration used when this object does not already hold an
engine. null means CompilerConfiguration.DEFAULT.
null Pre-built engine. When non-null, getCompilerConfiguration()
is ignored because the engine already carries its configuration.
null to let Main construct one Error renderer. null means groovysh's own trace.
nullCommand groups contributed by the embedder. They are resolved before groovysh's own commands, so a group may override a built-in command name.
null History file for the session. null means groovysh's own
groovysh_history in the user state directory.
nullCallback invoked once the reader and the command registry are both wired, immediately before the REPL starts, for settings this class does not model — the secondary prompt pattern, key bindings, reader options, and the completer.
null Prompt supplier invoked on each REPL iteration. null means "groovy> ".
null Result renderer. null means print result?.toString() via the printer.
nullRight-hand prompt supplier invoked on each REPL iteration.
null for noneTerminal to use instead of the one Main would build from CLI flags.
null to build the defaultWhether Main should print the groovysh banner (or the quiet version line).
true to print the banner