|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.springframework.shell.event.AbstractShellStatusPublisher org.springframework.shell.core.AbstractShell org.springframework.shell.core.JLineShell
public abstract class JLineShell
Uses the feature-rich JLine library to provide an interactive shell.
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.
Field Summary | |
---|---|
protected jline.ConsoleReader |
reader
|
protected ShellStatusListener |
statusListener
|
Fields inherited from class org.springframework.shell.core.AbstractShell |
---|
completionKeys, exitShellRequest, inBlockComment, logger, ROO_PROMPT, shellPrompt |
Fields inherited from class org.springframework.shell.event.AbstractShellStatusPublisher |
---|
shellStatus, shellStatusListeners |
Fields inherited from interface org.springframework.shell.core.Shell |
---|
WINDOW_TITLE_SLOT |
Constructor Summary | |
---|---|
JLineShell()
|
Method Summary | |
---|---|
protected void |
closeShell()
Should be called by a subclass before deactivating the shell. |
protected jline.ConsoleReader |
createAnsiWindowsReader()
|
protected jline.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. |
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. |
Methods inherited from class org.springframework.shell.core.AbstractShell |
---|
blockCommentBegin, blockCommentFinish, date, executeCommand, executeScriptLine, findResources, flashCustom, getExecutionStrategy, getExitShellRequest, getHome, getParser, getShellPrompt, handleExecutionResult, inlineComment, logCommandIfRequired, props, script, version, versionInfo |
Methods inherited from class org.springframework.shell.event.AbstractShellStatusPublisher |
---|
addShellStatusListener, getShellStatus, removeShellStatusListener, setShellStatus, setShellStatus |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface org.springframework.shell.core.Shell |
---|
executeCommand, getExitShellRequest, getHome |
Methods inherited from interface org.springframework.shell.event.ShellStatusProvider |
---|
addShellStatusListener, getShellStatus, removeShellStatusListener |
Methods inherited from interface org.springframework.shell.core.ShellPromptAccessor |
---|
getShellPrompt |
Field Detail |
---|
protected jline.ConsoleReader reader
protected ShellStatusListener statusListener
Constructor Detail |
---|
public JLineShell()
Method Detail |
---|
public void run()
run
in interface Runnable
protected jline.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.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()
Shell
promptLoop
in interface Shell
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
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |