Search in sources :

Example 1 with DefaultHistory

use of org.jline.reader.impl.history.DefaultHistory in project herddb by diennea.

the class HerdDBCLI method runSqlConsole.

private static void runSqlConsole(Connection connection, Statement statement, boolean pretty) throws IOException {
    Terminal terminal = TerminalBuilder.builder().system(true).build();
    LineReader reader = LineReaderBuilder.builder().history(new DefaultHistory()).terminal(terminal).build();
    String prompt = "herd: ";
    while (true) {
        String line = null;
        try {
            line = reader.readLine(prompt);
            if (line == null) {
                return;
            }
            executeStatement(true, true, false, false, line, statement, null, false, pretty);
        } catch (UserInterruptException | EndOfFileException e) {
            return;
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
Also used : EndOfFileException(org.jline.reader.EndOfFileException) LineReader(org.jline.reader.LineReader) DefaultHistory(org.jline.reader.impl.history.DefaultHistory) UserInterruptException(org.jline.reader.UserInterruptException) Terminal(org.jline.terminal.Terminal) ScriptException(javax.script.ScriptException) EndOfFileException(org.jline.reader.EndOfFileException) ParseException(org.apache.commons.cli.ParseException) CompilationFailedException(org.codehaus.groovy.control.CompilationFailedException) SQLException(java.sql.SQLException) IOException(java.io.IOException) ExecutionException(java.util.concurrent.ExecutionException) UserInterruptException(org.jline.reader.UserInterruptException)

Aggregations

IOException (java.io.IOException)1 SQLException (java.sql.SQLException)1 ExecutionException (java.util.concurrent.ExecutionException)1 ScriptException (javax.script.ScriptException)1 ParseException (org.apache.commons.cli.ParseException)1 CompilationFailedException (org.codehaus.groovy.control.CompilationFailedException)1 EndOfFileException (org.jline.reader.EndOfFileException)1 LineReader (org.jline.reader.LineReader)1 UserInterruptException (org.jline.reader.UserInterruptException)1 DefaultHistory (org.jline.reader.impl.history.DefaultHistory)1 Terminal (org.jline.terminal.Terminal)1