Class SimpleShell

All Implemented Interfaces:
Shell

public class SimpleShell extends SimpleCommandSupport implements Shell
A simple implementation of the Shell interface based on a library of SimpleCommands.
  • Constructor Details

    • SimpleShell

      public SimpleShell()
  • Method Details

    • newShellSession

      public ShellSession newShellSession(ShellRequest request) throws IOException
      Description copied from interface: Shell
      Create a new interactive shell session.

      If the request fails, this method should return null and write an error message to request.getTerminal().

      Specified by:
      newShellSession in interface Shell
      Parameters:
      request - interactive shell request
      Returns:
      interactive session, or null on failure
      Throws:
      IOException - if an I/O error occurs
    • newShellSession

      public ShellSession newShellSession(ShellRequest request, org.jline.reader.LineReader reader) throws IOException
      Alternate ssession creator for when a LineReader is already constructed.
      Parameters:
      request - session request
      reader - console line reader
      Returns:
      new session
      Throws:
      IOException - if an I/O error occurs
      IllegalArgumentException - if any parameter is null
    • getGreeting

      public String getGreeting()
      Get the welcome greeting.
      Returns:
      welcome greeting, or null for none
    • getNormalPrompt

      public String getNormalPrompt()
      Get the normal prompt.
      Returns:
      the normal prompt
    • getContinuationPrompt

      public String getContinuationPrompt()
      Get the continuation line prompt.
      Returns:
      the continuation line prompt
    • buildLineReader

      protected org.jline.reader.LineReader buildLineReader(ShellRequest request)
      Construct a LineReader for a new shell session.

      The implementation in SimpleShell invokes createLineReaderBuilder(org.dellroad.jct.core.ShellRequest) to create and configure the builder, then just returns LineReaderBuilder.build().

      Parameters:
      request - associated shell request
      Returns:
      new terminal line reader
    • createLineReaderBuilder

      protected org.jline.reader.LineReaderBuilder createLineReaderBuilder(ShellRequest request)
      Create and configure a LineReaderBuilder for a new shell session.
      Parameters:
      request - associated shell request
      Returns:
      builder for terminal line reader