Package org.apache.groovy.groovysh
Class GroovyshOptions
java.lang.Object
org.apache.groovy.groovysh.GroovyshOptions
Configuration for embedding groovysh programmatically via
Main.start(GroovyshOptions, String[]).
Where a setting has an equivalent on JLine's 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().
- Since:
- 7.0.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classBuilder forGroovyshOptions.static interfaceHandles an error thrown by the REPL loop.static interfaceHandles a value produced by the REPL loop. -
Method Summary
Modifier and TypeMethodDescriptionstatic GroovyshOptions.Builderbuilder()Creates a builder for embedding options.Binding variables installed on the engine before the REPL starts.Compiler configuration used when this object does not already hold anengine.Pre-built engine.Error renderer.List<org.jline.shell.CommandGroup>Command groups contributed by the embedder.History file for the session.BiConsumer<org.jline.reader.LineReader,org.apache.groovy.groovysh.jline.GroovySystemRegistry> 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.Prompt supplier invoked on each REPL iteration.Result renderer.Right-hand prompt supplier invoked on each REPL iteration.org.jline.terminal.TerminalTerminal to use instead of the oneMainwould build from CLI flags.booleanWhetherMainshould print the groovysh banner (or the quiet version line).
-
Method Details
-
builder
Creates a builder for embedding options.- Returns:
- a new builder with default values
-
getCompilerConfiguration
Compiler configuration used when this object does not already hold anengine.nullmeansCompilerConfiguration.DEFAULT.- Returns:
- the compiler configuration, or
null
-
getEngine
Pre-built engine. When non-null,getCompilerConfiguration()is ignored because the engine already carries its configuration.- Returns:
- the engine, or
nullto letMainconstruct one
-
getBindings
Binding variables installed on the engine before the REPL starts.- Returns:
- an unmodifiable map, never
null
-
getGroups
Command groups contributed by the embedder. They are resolved before groovysh's own commands, so a group may override a built-in command name.- Returns:
- an unmodifiable list, never
null
-
getPrompt
Prompt supplier invoked on each REPL iteration.nullmeans"groovy> ".- Returns:
- the prompt supplier, or
null
-
getRightPrompt
Right-hand prompt supplier invoked on each REPL iteration.- Returns:
- the right prompt supplier, or
nullfor none
-
getResultHandler
Result renderer.nullmeans printresult?.toString()via the printer.- Returns:
- the result handler, or
null
-
getErrorHandler
Error renderer.nullmeans groovysh's own trace.- Returns:
- the error handler, or
null
-
isShowBanner
public boolean isShowBanner()WhetherMainshould print the groovysh banner (or the quiet version line).- Returns:
trueto print the banner
-
getTerminal
public org.jline.terminal.Terminal getTerminal()Terminal to use instead of the oneMainwould build from CLI flags.- Returns:
- the terminal, or
nullto build the default
-
getHistoryFile
History file for the session.nullmeans groovysh's owngroovysh_historyin the user state directory.- Returns:
- the history file, or
null
-
getOnReaderReady
public BiConsumer<org.jline.reader.LineReader,org.apache.groovy.groovysh.jline.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.- Returns:
- the callback, or
null
-