Class BaseTerminal

java.lang.Object
nz.org.riskscape.engine.cli.BaseTerminal
All Implemented Interfaces:
Consumer<nz.org.riskscape.problem.Problem>, nz.org.riskscape.cli.Terminal, nz.org.riskscape.problem.ProblemSink
Direct Known Subclasses:
JlineTerminal

public abstract class BaseTerminal extends Object implements nz.org.riskscape.problem.ProblemSink, nz.org.riskscape.cli.Terminal

Wraps all of the user-facing parts of the CLI

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
     
    static nz.org.riskscape.picocli.CommandLine.Help.Ansi
    A default CommandLine.Help.Ansi object to use when building CommandLine.Help.Ansi.Text objects from Strings.
    boolean
    Whether to include stack traces in problems when printed XXX this is currently broken, as the stack traces get filled lazily
    static final int
     

    Fields inherited from interface nz.org.riskscape.problem.ProblemSink

    DEVNULL

    Fields inherited from interface nz.org.riskscape.cli.Terminal

    ELLIPSIS, EMPTY_TEXT, NO_STYLES
  • Constructor Summary

    Constructors
    Constructor
    Description
    BaseTerminal(nz.org.riskscape.engine.i18n.Messages messages)
     
    BaseTerminal(nz.org.riskscape.engine.i18n.Messages messages, Locale locale)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    nz.org.riskscape.picocli.CommandLine.Help.Ansi
     
    nz.org.riskscape.cli.InterruptHandler
     
    The locale for this terminal.
    boolean
     
    void
    log(nz.org.riskscape.problem.Problem problem)
    Allows this Terminal to act as a ProblemSink - dumps any messages out to stderr along with some basic formatting to make them stick out a bit
    nz.org.riskscape.cli.InterruptHandler
    setFallbackHandler(nz.org.riskscape.cli.InterruptHandler newFallbackHandler)
     
    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, wait

    Methods inherited from interface java.util.function.Consumer

    andThen

    Methods inherited from interface nz.org.riskscape.problem.ProblemSink

    accept

    Methods 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 defaultAnsi

      A default CommandLine.Help.Ansi object to use when building CommandLine.Help.Ansi.Text objects from Strings.

    • showStackTrace

      public boolean showStackTrace

      Whether 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

      public BaseTerminal(nz.org.riskscape.engine.i18n.Messages messages, Locale locale)
  • Method Details

    • wrapAsUncloseable

      public static PrintStream wrapAsUncloseable(PrintStream toWrap)

      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 Terminal to act as a ProblemSink - dumps any messages out to stderr along with some basic formatting to make them stick out a bit

      Specified by:
      log in interface nz.org.riskscape.problem.ProblemSink
    • setFallbackHandler

      public nz.org.riskscape.cli.InterruptHandler setFallbackHandler(nz.org.riskscape.cli.InterruptHandler newFallbackHandler)
      Specified by:
      setFallbackHandler in interface nz.org.riskscape.cli.Terminal
    • isTTY

      public boolean isTTY()
      Specified by:
      isTTY in interface nz.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:
      getAnsi in interface nz.org.riskscape.cli.Terminal
    • getLocale

      public Locale 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:
      getLocale in interface nz.org.riskscape.cli.Terminal
    • getFallbackHandler

      public nz.org.riskscape.cli.InterruptHandler getFallbackHandler()