Skip to content

LineReader

Guillaume Nodet edited this page Apr 27, 2018 · 6 revisions

The LineReader interface allows reading lines from a terminal, with full input/line editing.

Instances of LineReader can be obtained using the LineReaderBuilder class:

  Terminal terminal = ...;
  LineReader lineReader = LineReaderBuilder.builder()
                              .terminal(terminal)
                              .build();

LineReader building options

The builder can be customised to create more suitable line readers:

   LineReader lineReader = LineReaderBuilder.builder()
                              .terminal(terminal)
                              .completer(new MyCompleter())
                              .highlighter(new MyHighlighter())
                              .parser(new MyParser())
                              .build();
Option Description
terminal The Terminal to use
appName The application name
variables A Map<String, Object> containing variables
completer The Completer component to use
history The History component to use
highlighter The [Highlighter](Highlighting and parsing) component to use
parser The [Parser](Highlighting and parsing) component to use
expander The [Expander](Variable expansion) component to use

Using LineReader

See Using line readers.