Package org.jline.shell
Class Shell
java.lang.Object
org.jline.shell.Shell
- All Implemented Interfaces:
AutoCloseable
An interactive shell that runs a read-eval-print loop (REPL)
using a
CommandDispatcher for command execution.
The shell is a thin REPL loop. The dispatcher is injected or auto-created
as a DefaultCommandDispatcher.
Use builder() to create a shell:
Shell shell = Shell.builder()
.terminal(terminal)
.prompt("myapp> ")
.dispatcher(dispatcher)
.groups(group1, group2)
.build();
shell.run();
- Since:
- 4.0
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic ShellBuilderbuilder()Creates a newShellBuilder.voidclose()Closes this shell, releasing the dispatcher and optionally the terminal.Returns the command dispatcher used by this shell.booleanReturns whether the shell is currently running.reader()Returns the line reader used by this shell.voidrun()Runs the interactive REPL loop.voidstop()Stops the REPL loop.terminal()Returns the terminal used by this shell.
-
Method Details
-
builder
-
run
-
stop
public void stop()Stops the REPL loop. The current or next iteration will exit. -
isRunning
public boolean isRunning()Returns whether the shell is currently running.- Returns:
- true if running
-
terminal
-
reader
-
dispatcher
Returns the command dispatcher used by this shell.- Returns:
- the command dispatcher
-
close
public void close()Closes this shell, releasing the dispatcher and optionally the terminal.- Specified by:
closein interfaceAutoCloseable
-