Class CLIContext

java.lang.Object
org.jpos.q2.CLIContext

public class CLIContext extends Object
Holds the I/O streams, LineReader, and metadata for a CLI session.
  • Method Details

    • getActiveSubSystem

      Returns the name of the active CLI sub-system.
      Returns:
      the active sub-system name, or null
    • setActiveSubSystem

      public void setActiveSubSystem(String subSystem)
      Sets the active CLI sub-system by name.
      Parameters:
      subSystem - the name of the new active sub-system
    • isStopped

      public boolean isStopped()
      Returns true if this CLI session has been stopped.
      Returns:
      true if stopped
    • setStopped

      public void setStopped(boolean stopped)
      Marks this CLI session as stopped.
      Parameters:
      stopped - true to stop
    • getReader

      public org.jline.reader.LineReader getReader()
      Returns the JLine3 LineReader for interactive input.
      Returns:
      the LineReader
    • setReader

      public void setReader(org.jline.reader.LineReader reader)
      Sets the JLine3 LineReader.
      Parameters:
      reader - the LineReader
    • getOutputStream

      Returns the standard output stream for this session.
      Returns:
      the output stream
    • getErrorStream

      Returns the error stream for this session.
      Returns:
      the error stream
    • getInputStream

      Returns the input stream for this session.
      Returns:
      the input stream
    • getUserData

      Returns the mutable user-data map for sharing state across CLI commands.
      Returns:
      user data map
    • isInteractive

      public boolean isInteractive()
      Returns true if this session is interactive (has a LineReader).
      Returns:
      true if interactive
    • getCLI

      public CLI getCLI()
      Returns the CLI instance managing this context.
      Returns:
      the CLI
    • printUserData

      public void printUserData()
      Prints all user-data entries to the output stream.
    • printThrowable

      public void printThrowable(Throwable t)
      Prints a throwable stack trace to the error stream.
      Parameters:
      t - the throwable to print
    • printLoggeable

      public void printLoggeable(Loggeable l, String indent)
      Dumps a Loggeable to the output stream.
      Parameters:
      l - the Loggeable to dump
      indent - indentation prefix
    • print

      public void print(String s)
      Prints a string to the output stream (no trailing newline).
      Parameters:
      s - the string to print
    • println

      public void println(String s)
      Prints a string to the output stream followed by a newline.
      Parameters:
      s - the string to print
    • confirm

      public boolean confirm(String prompt)
      Prompts the user for confirmation.
      Parameters:
      prompt - the confirmation prompt
      Returns:
      true if user confirmed
    • readSecurely

      public String readSecurely(String prompt)
      Reads a string from the user without echoing (e.g. for passwords).
      Parameters:
      prompt - the prompt to display
      Returns:
      the input string
    • builder

      public static CLIContext.Builder builder()
      Returns a new Builder for constructing a CLIContext.
      Returns:
      a new Builder