Package org.jboss.as.cli.impl
Class ReadlineConsole
- java.lang.Object
-
- org.jboss.as.cli.impl.ReadlineConsole
-
public class ReadlineConsole extends Object
Integration point with aesh-readline. There are multiple paths when the CLI exits.- quit command: Command ctx is terminated, console is closed, terminal connection reading thread is interrupted, Main thread exit, jvm exit handlers are called
- Ctrl-C: can be received as an OS signal or parsed by aesh. In both cases interruptHandler is called, the connection is closed, terminal connection reading thread is interrupted, Main thread exit, jvm exit handlers are called. If a prompt is in progress, the reading thread will be interrupted too.
- Ctrl-D (without characters typed): Only parsed by aesh, no native signal raised. In both cases, the connection is closed by aesh, terminal connection reading thread is interrupted, Main thread exit, jvm exit handlers are called. If a prompt is in progress, the reading thread will be interrupted too. Because Ctrl-D is not a native signal, it can't be handled during the execution of a command. Only Ctrl-C can be used to interrupt the CLI.
- Author:
- jdenise@redhat.com
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceReadlineConsole.Settingsstatic classReadlineConsole.SettingsBuilder
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddCompleter(org.aesh.readline.completion.Completion<? extends org.aesh.readline.completion.CompleteOperation> completer)voidclearScreen()voidforcePagingOutput(boolean forcePaging)StringformatColumns(Collection<String> list)org.aesh.terminal.ConnectiongetConnection()CommandHistorygetHistory()org.aesh.readline.PromptgetPrompt()intgetTerminalHeight()intgetTerminalWidth()StringhandleBuiltins(String line)booleanisPagingOutputActive()booleanisPagingOutputEnabled()Public for testing purpose only.voidprint(String line, boolean collect)voidprintNewLine(boolean collect)int[]read()org.aesh.readline.terminal.KeyreadKey()StringreadLine(String prompt)StringreadLine(String prompt, Character mask)Prompt a user.StringreadLine(org.aesh.readline.Prompt prompt)StringreadLine(org.aesh.readline.Prompt prompt, org.aesh.readline.completion.Completion completer)booleanrunning()voidsetActionCallback(Consumer<String> callback)voidsetCompletionHandler(org.aesh.readline.completion.CompletionHandler<? extends org.aesh.readline.completion.CompleteOperation> ch)This has the side effect to create the internal readline instance.voidsetPrompt(String prompt)voidsetPrompt(org.aesh.readline.Prompt prompt)voidstart()voidstop()
-
-
-
Method Detail
-
setCompletionHandler
public void setCompletionHandler(org.aesh.readline.completion.CompletionHandler<? extends org.aesh.readline.completion.CompleteOperation> ch)
This has the side effect to create the internal readline instance.- Parameters:
ch- The Completion Handler.
-
addCompleter
public void addCompleter(org.aesh.readline.completion.Completion<? extends org.aesh.readline.completion.CompleteOperation> completer)
-
getHistory
public CommandHistory getHistory()
-
clearScreen
public void clearScreen()
-
formatColumns
public String formatColumns(Collection<String> list)
-
print
public void print(String line, boolean collect)
-
readKey
public org.aesh.readline.terminal.Key readKey() throws InterruptedException, IOException- Throws:
InterruptedExceptionIOException
-
read
public int[] read() throws InterruptedException, IOException- Throws:
InterruptedExceptionIOException
-
printNewLine
public void printNewLine(boolean collect)
-
readLine
public String readLine(String prompt) throws IOException, InterruptedException
- Throws:
IOExceptionInterruptedException
-
readLine
public String readLine(String prompt, Character mask) throws InterruptedException, IOException
Prompt a user. The complexity of this method is implied by the Ctrl-C handling. When Ctrl-C occurs, the Exit hook will call this.close that interrupts the thread calling this operation.We have 2 cases.
1) prompting prior to have started the console: - Must start a new connection. - Make it non blocking. - Wait on latch to resync and to catch Thread.interrupt.
2) prompting after to have started the console: - No need to open the connection. - Wait on latch to resync and to catch Thread.interrupt.
- Parameters:
prompt-mask-- Returns:
- Throws:
IOExceptionInterruptedException
-
readLine
public String readLine(org.aesh.readline.Prompt prompt) throws InterruptedException, IOException
- Throws:
InterruptedExceptionIOException
-
readLine
public String readLine(org.aesh.readline.Prompt prompt, org.aesh.readline.completion.Completion completer) throws InterruptedException, IOException
- Throws:
InterruptedExceptionIOException
-
getTerminalWidth
public int getTerminalWidth()
-
getTerminalHeight
public int getTerminalHeight()
-
start
public void start() throws IOException- Throws:
IOException
-
stop
public void stop()
-
running
public boolean running()
-
setPrompt
public void setPrompt(String prompt)
-
setPrompt
public void setPrompt(org.aesh.readline.Prompt prompt)
-
isPagingOutputEnabled
public boolean isPagingOutputEnabled()
Public for testing purpose only.- Returns:
-
isPagingOutputActive
public boolean isPagingOutputActive()
-
forcePagingOutput
public void forcePagingOutput(boolean forcePaging)
-
getPrompt
public org.aesh.readline.Prompt getPrompt()
-
getConnection
public org.aesh.terminal.Connection getConnection()
-
-