Class BaseTerminal
- All Implemented Interfaces:
Consumer<nz.org.riskscape.problem.Problem>,nz.org.riskscape.cli.Terminal,nz.org.riskscape.problem.ProblemSink
- Direct Known Subclasses:
JlineTerminal
Wraps all of the user-facing parts of the CLI
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intstatic nz.org.riskscape.picocli.CommandLine.Help.AnsiA defaultCommandLine.Help.Ansiobject to use when buildingCommandLine.Help.Ansi.Textobjects fromStrings.booleanWhether to include stack traces in problems when printed XXX this is currently broken, as the stack traces get filled lazilystatic final intFields inherited from interface nz.org.riskscape.problem.ProblemSink
DEVNULLFields inherited from interface nz.org.riskscape.cli.Terminal
ELLIPSIS, EMPTY_TEXT, NO_STYLES -
Constructor Summary
ConstructorsConstructorDescriptionBaseTerminal(nz.org.riskscape.engine.i18n.Messages messages) BaseTerminal(nz.org.riskscape.engine.i18n.Messages messages, Locale locale) Creates a newBaseTerminalinstance. -
Method Summary
Modifier and TypeMethodDescriptionnz.org.riskscape.picocli.CommandLine.Help.AnsigetAnsi()nz.org.riskscape.cli.InterruptHandlerThe locale for this terminal.booleanisTTY()voidlog(nz.org.riskscape.problem.Problem problem) Allows thisTerminalto act as aProblemSink- dumps any messages out to stderr along with some basic formatting to make them stick out a bitnz.org.riskscape.cli.InterruptHandlersetFallbackHandler(nz.org.riskscape.cli.InterruptHandler newFallbackHandler) static PrintStreamwrapAsUncloseable(PrintStream toWrap) Wraps a PrintStream in one that will inhibit the auto closing of the underlying output stream.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface nz.org.riskscape.problem.ProblemSink
acceptMethods inherited from interface nz.org.riskscape.cli.Terminal
getAnsiErr, getAnsiOut, getDisplayHeight, getDisplayWidth, getErr, getIn, getOut, println, printProblems, printProblems, readline, updateStatus
-
Field Details
-
DEFAULT_TTY_WIDTH
public static final int DEFAULT_TTY_WIDTH- See Also:
-
TERMINAL_HEIGHT_UNLIMITED
public static final int TERMINAL_HEIGHT_UNLIMITED- See Also:
-
defaultAnsi
public static nz.org.riskscape.picocli.CommandLine.Help.Ansi defaultAnsiA default
CommandLine.Help.Ansiobject to use when buildingCommandLine.Help.Ansi.Textobjects fromStrings. -
showStackTrace
public boolean showStackTraceWhether to include stack traces in problems when printed XXX this is currently broken, as the stack traces get filled lazily
-
-
Constructor Details
-
BaseTerminal
public BaseTerminal(nz.org.riskscape.engine.i18n.Messages messages) -
BaseTerminal
Creates a new
BaseTerminalinstance.- Parameters:
messages-locale- The locale for this terminal. Note that while the terminal has a locale (typically read/setup from an environment variable), the terminal itself does not want to deal with internationalization issues, so don't start adding i18n code in here, please!
-
-
Method Details
-
wrapAsUncloseable
Wraps a PrintStream in one that will inhibit the auto closing of the underlying output stream.
- Parameters:
toWrap-- Returns:
- a print stream wrapping toWrap
-
log
public void log(nz.org.riskscape.problem.Problem problem) Allows this
Terminalto act as aProblemSink- dumps any messages out to stderr along with some basic formatting to make them stick out a bit- Specified by:
login interfacenz.org.riskscape.problem.ProblemSink
-
setFallbackHandler
public nz.org.riskscape.cli.InterruptHandler setFallbackHandler(nz.org.riskscape.cli.InterruptHandler newFallbackHandler) - Specified by:
setFallbackHandlerin interfacenz.org.riskscape.cli.Terminal
-
isTTY
public boolean isTTY()- Specified by:
isTTYin interfacenz.org.riskscape.cli.Terminal- Returns:
- true if this terminal is connected to a TTY.
-
getAnsi
public nz.org.riskscape.picocli.CommandLine.Help.Ansi getAnsi()- Specified by:
getAnsiin interfacenz.org.riskscape.cli.Terminal
-
getLocale
The locale for this terminal. Note that while the terminal has a locale (typically read/setup from an environment variable), the terminal itself does not want to deal with internationalization issues, so don't start adding i18n code in here, please!
- Specified by:
getLocalein interfacenz.org.riskscape.cli.Terminal
-
getFallbackHandler
public nz.org.riskscape.cli.InterruptHandler getFallbackHandler()
-