org.jline.reader.impl.completer.AggregateCompleter Java Examples

The following examples show how to use org.jline.reader.impl.completer.AggregateCompleter. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source Project: rug-cli   Author: atomist-attic   File: ShellUtils.java    License: GNU General Public License v3.0 7 votes vote down vote up
public static LineReader lineReader(File historyPath, Optional<SignalHandler> handler,
        Completer... completers) {
    // Protect the history file as may contain sensitive information
    FileUtils.setPermissionsToOwnerOnly(historyPath);

    // Create JLine LineReader
    History history = new DefaultHistory();
    LineReader reader = LineReaderBuilder.builder().terminal(terminal(handler)).history(history)
            .parser(new DefaultParser()).variable(LineReader.HISTORY_FILE, historyPath)
            .completer(new AggregateCompleter(completers)).highlighter(new DefaultHighlighter())
            .build();
    history.attach(reader);

    setOptions(reader);

    return reader;
}
 
Example #2
Source Project: presto   Author: prestosql   File: InputReader.java    License: Apache License 2.0 6 votes vote down vote up
public InputReader(Path historyFile, Completer... completers)
        throws IOException
{
    Terminal terminal = TerminalBuilder.builder()
            .name("Presto")
            .build();

    reader = LineReaderBuilder.builder()
            .terminal(terminal)
            .variable(HISTORY_FILE, historyFile)
            .variable(SECONDARY_PROMPT_PATTERN, colored("%P -> "))
            .variable(BLINK_MATCHING_PAREN, 0)
            .parser(new InputParser())
            .highlighter(new InputHighlighter())
            .completer(new AggregateCompleter(completers))
            .build();

    reader.unsetOpt(HISTORY_TIMESTAMPED);
}