public abstract class JLineShell extends AbstractShell implements Shell, Runnable
Due to Windows' lack of color ANSI services out-of-the-box, this implementation automatically detects the classpath presence of Jansi and uses it if present. This library is not necessary for *nix machines, which support colour ANSI without any special effort. This implementation has been written to use reflection in order to avoid hard dependencies on Jansi.
Modifier and Type | Field and Description |
---|---|
protected jline.console.ConsoleReader |
reader |
protected ShellStatusListener |
statusListener |
completionKeys, exceptionLogger, exitShellRequest, inBlockComment, logger, ROO_PROMPT, shellPrompt
shellStatus, shellStatusListeners
WINDOW_TITLE_SLOT
Constructor and Description |
---|
JLineShell() |
Modifier and Type | Method and Description |
---|---|
protected void |
closeShell()
Should be called by a subclass before deactivating the shell.
|
protected jline.console.ConsoleReader |
createAnsiWindowsReader() |
protected jline.console.ConsoleReader |
createConsoleReader()
Creates new jline ConsoleReader.
|
void |
flash(Level level,
String message,
String slot)
Simple implementation of
AbstractShell.flash(Level, String, String) that simply displays the message via the logger. |
String |
generatePromptUpdate(String existingPrompt)
Retrieves the latest prompt and if the latest prompt is different than the existing prompt,
the shellPrompt is updated.
|
protected abstract String |
getHistoryFileName()
get history file name from provider.
|
int |
getHistorySize() |
protected String |
getHomeAsString()
Obtains the "roo.home" from the system property, falling back to the current working directory if missing.
|
protected abstract String |
getProductName()
get product name
|
protected abstract String |
getPromptText()
get prompt text from provider.
|
String |
getStartupNotifications() |
protected String |
getVersion()
get version information
|
boolean |
isDevelopmentMode() |
protected void |
logCommandToOutput(String processedLine)
Allows a subclass to actually write the resulting logged command to some form of output.
|
void |
printBannerAndWelcome() |
void |
promptLoop()
Awaits user input, executes the command and displays the prompt to the user.
|
void |
run() |
void |
setDevelopmentMode(boolean developmentMode)
Indicates the shell should switch into a lower-level development mode.
|
void |
setHistorySize(int historySize) |
void |
setPromptPath(String path)
Base implementation of the
Shell.setPromptPath(String) method, designed for simple shell
implementations. |
void |
setPromptPath(String path,
boolean overrideStyle)
Default implementation of
Shell#setPromptPath(String, boolean)) method to satisfy STS compatibility. |
blockCommentBegin, blockCommentFinish, executeCommand, executeScriptLine, getExecutionStrategy, getExitShellRequest, getHome, getParser, getShellPrompt, handleExecutionResult, logCommandIfRequired, versionInfo
addShellStatusListener, getShellStatus, removeShellStatusListener, setShellStatus, setShellStatus
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
executeCommand, getExitShellRequest, getHome
addShellStatusListener, getShellStatus, removeShellStatusListener
getShellPrompt
protected jline.console.ConsoleReader reader
protected ShellStatusListener statusListener
protected jline.console.ConsoleReader createConsoleReader()
public void printBannerAndWelcome()
public String getStartupNotifications()
public void setPromptPath(String path)
AbstractShell
Shell.setPromptPath(String)
method, designed for simple shell
implementations. Advanced implementations (eg those that support ANSI codes etc) will likely want
to override this method and set the AbstractShell.shellPrompt
variable directly.setPromptPath
in interface Shell
setPromptPath
in class AbstractShell
path
- to set (can be null or empty; must NOT be formatted in any special way eg ANSI codes)public void setPromptPath(String path, boolean overrideStyle)
AbstractShell
Shell#setPromptPath(String, boolean))
method to satisfy STS compatibility.setPromptPath
in interface Shell
setPromptPath
in class AbstractShell
path
- to set (can be null or empty)protected jline.console.ConsoleReader createAnsiWindowsReader() throws Exception
Exception
public void flash(Level level, String message, String slot)
AbstractShell
AbstractShell.flash(Level, String, String)
that simply displays the message via the logger. It is
strongly recommended shell implementations override this method with a more effective approach.flash
in interface Shell
flash
in class AbstractShell
level
- the importance of the message (cannot be null)message
- to display (cannot be null, but may be empty)slot
- the identification slot for the message (cannot be null or empty)public void promptLoop()
promptLoop
in interface Shell
public String generatePromptUpdate(String existingPrompt)
existingPrompt
- The prompt that is recognized as the current prompt.public void setDevelopmentMode(boolean developmentMode)
Shell
setDevelopmentMode
in interface Shell
developmentMode
- true if development mode should be enabled, false otherwisepublic boolean isDevelopmentMode()
isDevelopmentMode
in interface Shell
protected void logCommandToOutput(String processedLine)
AbstractShell
AbstractShell.logCommandIfRequired(String, boolean)
.
Implementations should invoke AbstractShell.getExitShellRequest()
to monitor any attempts to exit the shell and
release resources such as output log files.
logCommandToOutput
in class AbstractShell
processedLine
- the line that should be appended to some type of output (excluding the \n character)protected String getHomeAsString()
getHomeAsString
in class AbstractShell
protected void closeShell()
protected abstract String getHistoryFileName()
protected abstract String getPromptText()
protected abstract String getProductName()
protected String getVersion()
public int getHistorySize()
public void setHistorySize(int historySize)
historySize
- the historySize to set