Package org.dellroad.jct.core.simple
Class SimpleShell
java.lang.Object
org.dellroad.jct.core.simple.SimpleCommandSupport
org.dellroad.jct.core.simple.SimpleShell
- All Implemented Interfaces:
Shell
A simple implementation of the
Shell
interface based on a library of SimpleCommand
s.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
DefaultShellSession
implementation used bySimpleShell
.protected class
A simpleCompleter
for command names.Nested classes/interfaces inherited from class org.dellroad.jct.core.simple.SimpleCommandSupport
SimpleCommandSupport.FoundCommand
-
Field Summary
Fields inherited from class org.dellroad.jct.core.simple.SimpleCommandSupport
commandBundles, commandLineParser
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected org.jline.reader.LineReader
buildLineReader
(ShellRequest request) Construct aLineReader
for a new shell session.protected org.jline.reader.LineReaderBuilder
createLineReaderBuilder
(ShellRequest request) Create and configure aLineReaderBuilder
for a new shell session.Get the continuation line prompt.Get the welcome greeting.Get the normal prompt.newShellSession
(ShellRequest request) Create a new interactive shell session.newShellSession
(ShellRequest request, org.jline.reader.LineReader reader) Alternate ssession creator for when aLineReader
is already constructed.Methods inherited from class org.dellroad.jct.core.simple.SimpleCommandSupport
buildCommandMap, findCommand, findCommand, findCommand, getCommandBundles, getCommandLineParser, setCommandLineParser
-
Constructor Details
-
SimpleShell
public SimpleShell()
-
-
Method Details
-
newShellSession
Description copied from interface:Shell
Create a new interactive shell session.If the request fails, this method should return null and write an error message to
request.
getTerminal()
.- Specified by:
newShellSession
in interfaceShell
- Parameters:
request
- interactive shell request- Returns:
- interactive session, or null on failure
- Throws:
IOException
- if an I/O error occurs
-
newShellSession
public ShellSession newShellSession(ShellRequest request, org.jline.reader.LineReader reader) throws IOException Alternate ssession creator for when aLineReader
is already constructed.- Parameters:
request
- session requestreader
- console line reader- Returns:
- new session
- Throws:
IOException
- if an I/O error occursIllegalArgumentException
- if any parameter is null
-
getGreeting
Get the welcome greeting.- Returns:
- welcome greeting, or null for none
-
getNormalPrompt
Get the normal prompt.- Returns:
- the normal prompt
-
getContinuationPrompt
Get the continuation line prompt.- Returns:
- the continuation line prompt
-
buildLineReader
Construct aLineReader
for a new shell session.The implementation in
SimpleShell
invokescreateLineReaderBuilder(org.dellroad.jct.core.ShellRequest)
to create and configure the builder, then just returnsLineReaderBuilder.build()
.- Parameters:
request
- associated shell request- Returns:
- new terminal line reader
-
createLineReaderBuilder
Create and configure aLineReaderBuilder
for a new shell session.- Parameters:
request
- associated shell request- Returns:
- builder for terminal line reader
-