Class CLIContext
java.lang.Object
org.jpos.q2.CLIContext
Holds the I/O streams, LineReader, and metadata for a CLI session.
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionstatic CLIContext.Builderbuilder()Returns a new Builder for constructing a CLIContext.booleanPrompts the user for confirmation.Returns the name of the active CLI sub-system.getCLI()Returns the CLI instance managing this context.Returns the error stream for this session.Returns the input stream for this session.Returns the standard output stream for this session.org.jline.reader.LineReaderReturns the JLine3 LineReader for interactive input.Returns the mutable user-data map for sharing state across CLI commands.booleanReturns true if this session is interactive (has a LineReader).booleanReturns true if this CLI session has been stopped.voidPrints a string to the output stream (no trailing newline).voidPrints a string to the output stream followed by a newline.voidprintLoggeable(Loggeable l, String indent) Dumps a Loggeable to the output stream.voidPrints a throwable stack trace to the error stream.voidPrints all user-data entries to the output stream.readSecurely(String prompt) Reads a string from the user without echoing (e.g.voidsetActiveSubSystem(String subSystem) Sets the active CLI sub-system by name.voidsetReader(org.jline.reader.LineReader reader) Sets the JLine3 LineReader.voidsetStopped(boolean stopped) Marks this CLI session as stopped.
-
Method Details
-
getActiveSubSystem
Returns the name of the active CLI sub-system.- Returns:
- the active sub-system name, or null
-
setActiveSubSystem
Sets the active CLI sub-system by name.- Parameters:
subSystem- the name of the new active sub-system
-
isStopped
Returns true if this CLI session has been stopped.- Returns:
- true if stopped
-
setStopped
Marks this CLI session as stopped.- Parameters:
stopped- true to stop
-
getReader
Returns the JLine3 LineReader for interactive input.- Returns:
- the LineReader
-
setReader
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
Returns true if this session is interactive (has a LineReader).- Returns:
- true if interactive
-
getCLI
-
printUserData
Prints all user-data entries to the output stream. -
printThrowable
Prints a throwable stack trace to the error stream.- Parameters:
t- the throwable to print
-
printLoggeable
Dumps a Loggeable to the output stream.- Parameters:
l- the Loggeable to dumpindent- indentation prefix
-
print
-
println
-
confirm
-
readSecurely
Reads a string from the user without echoing (e.g. for passwords).- Parameters:
prompt- the prompt to display- Returns:
- the input string
-
builder
Returns a new Builder for constructing a CLIContext.- Returns:
- a new Builder
-