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, exitShellRequest, inBlockComment, logger, ROO_PROMPT, shellPromptshellStatus, shellStatusListenersWINDOW_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. |
void |
generatePromptUpdate(String existingPrompt) |
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()
Presents a console prompt and allows the user to interact with the shell.
|
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, versionInfoaddShellStatusListener, getShellStatus, removeShellStatusListener, setShellStatus, setShellStatusclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitexecuteCommand, getExitShellRequest, getHomeaddShellStatusListener, getShellStatus, removeShellStatusListenergetShellPromptprotected jline.console.ConsoleReader reader
protected ShellStatusListener statusListener
protected jline.console.ConsoleReader createConsoleReader()
public void printBannerAndWelcome()
public String getStartupNotifications()
public void setPromptPath(String path)
AbstractShellShell.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 ShellsetPromptPath in class AbstractShellpath - 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)
AbstractShellShell#setPromptPath(String, boolean)) method to satisfy STS compatibility.setPromptPath in interface ShellsetPromptPath in class AbstractShellpath - to set (can be null or empty)protected jline.console.ConsoleReader createAnsiWindowsReader()
throws Exception
Exceptionpublic void flash(Level level, String message, String slot)
AbstractShellAbstractShell.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 Shellflash in class AbstractShelllevel - 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()
ShellpromptLoop in interface Shellpublic void generatePromptUpdate(String existingPrompt)
public void setDevelopmentMode(boolean developmentMode)
ShellsetDevelopmentMode in interface ShelldevelopmentMode - true if development mode should be enabled, false otherwisepublic boolean isDevelopmentMode()
isDevelopmentMode in interface Shellprotected void logCommandToOutput(String processedLine)
AbstractShellAbstractShell.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 AbstractShellprocessedLine - the line that should be appended to some type of output (excluding the \n character)protected String getHomeAsString()
getHomeAsString in class AbstractShellprotected 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