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 SimpleCommands.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classDefaultShellSessionimplementation used bySimpleShell.protected classA simpleCompleterfor 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.LineReaderbuildLineReader(ShellRequest request) Construct aLineReaderfor a new shell session.protected org.jline.reader.LineReaderBuildercreateLineReaderBuilder(ShellRequest request) Create and configure aLineReaderBuilderfor 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 aLineReaderis 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:ShellCreate a new interactive shell session.If the request fails, this method should return null and write an error message to
request.getTerminal().- Specified by:
newShellSessionin 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 aLineReaderis 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 aLineReaderfor a new shell session.The implementation in
SimpleShellinvokescreateLineReaderBuilder(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 aLineReaderBuilderfor a new shell session.- Parameters:
request- associated shell request- Returns:
- builder for terminal line reader
-