Class 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
    • Method Detail

      • setActionCallback

        public void setActionCallback​(Consumer<String> callback)
      • 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)
      • clearScreen

        public void clearScreen()
      • print

        public void print​(String line,
                          boolean collect)
      • printNewLine

        public void printNewLine​(boolean collect)
      • 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:
        IOException
        InterruptedException
      • getTerminalWidth

        public int getTerminalWidth()
      • getTerminalHeight

        public int getTerminalHeight()
      • 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()
      • handleBuiltins

        public String handleBuiltins​(String line)