@EventListener public void onContextClosedEvent(ContextClosedEvent event) throws IOException { history.save(); } }
@EventListener public void onContextClosedEvent(ContextClosedEvent event) throws IOException { history.save(); } }
@Override public void run() { try { history.save(); } catch (IOException e) { System.err.println("Failed to flush command history! " + e); } } }));
public void close() { if (closed.compareAndSet(false, true)) { if (running) { try { reader.getHistory().save(); } catch (IOException e) { // ignore } } running = false; if (thread != Thread.currentThread() && thread != null) { thread.interrupt(); } if (closeCallback != null) { closeCallback.run(); } if (terminal instanceof AutoCloseable) { try { ((AutoCloseable) terminal).close(); } catch (Exception e) { // Ignore } } if (session != null) session.close(); } }
public void close() { if (closed.compareAndSet(false, true)) { if (running) { try { reader.getHistory().save(); } catch (IOException e) { // ignore } } running = false; if (thread != Thread.currentThread() && thread != null) { thread.interrupt(); } if (closeCallback != null) { closeCallback.run(); } if (terminal instanceof AutoCloseable) { try { ((AutoCloseable) terminal).close(); } catch (Exception e) { // Ignore } } if (session != null) session.close(); } }
private void setLineReaderHistoryIntVariable( String variableName, String value, SqlLineProperty property) { LineReader lineReader = sqlLine.getLineReader(); if (lineReader == null) { return; } int currentValue = getInt(property); try { if (DEFAULT.equals(value)) { if (currentValue == (Integer) property.defaultValue()) { return; } else { lineReader.setVariable(variableName, property.defaultValue()); lineReader.getHistory().save(); propertiesMap.put(property, property.defaultValue()); return; } } int parsedValue = Integer.parseInt(value); if (parsedValue == currentValue) { return; } else { lineReader.setVariable(variableName, parsedValue); lineReader.getHistory().save(); propertiesMap.put(property, parsedValue); } } catch (Exception e) { sqlLine.handleException(e); } }
private void setLineReaderHistoryIntVariable( String variableName, String value, SqlLineProperty property) { LineReader lineReader = sqlLine.getLineReader(); if (lineReader == null) { return; } int currentValue = getInt(property); try { if (DEFAULT.equals(value)) { if (currentValue == (Integer) property.defaultValue()) { return; } else { lineReader.setVariable(variableName, property.defaultValue()); lineReader.getHistory().save(); propertiesMap.put(property, property.defaultValue()); return; } } int parsedValue = Integer.parseInt(value); if (parsedValue == currentValue) { return; } else { lineReader.setVariable(variableName, parsedValue); lineReader.getHistory().save(); propertiesMap.put(property, parsedValue); } } catch (Exception e) { sqlLine.handleException(e); } }
private void runInteractive() { SignalHandler handler = signal -> _logger.debugf("Client: Ignoring signal: %s\n", signal); Signal.handle(new Signal("INT"), handler); try { while (!_exit) { try { String rawLine = _reader.readLine("batfish> "); if (rawLine == null) { break; } processCommand(rawLine); } catch (UserInterruptException e) { continue; } } } catch (EndOfFileException e) { // ignored } catch (Throwable t) { t.printStackTrace(); } finally { try { _reader.getHistory().save(); } catch (IOException e) { e.printStackTrace(); } } }
public void setHistoryFile(String historyFile) { final String currentValue = get(HISTORY_FILE); if (Objects.equals(currentValue, historyFile) || Objects.equals(currentValue, Commands.expand(historyFile))) { return; } if (DEFAULT.equalsIgnoreCase(historyFile)) { set(HISTORY_FILE, DEFAULT); } else { propertiesMap.put(HISTORY_FILE, Commands.expand(historyFile)); } if (sqlLine != null && sqlLine.getLineReader() != null) { History history = sqlLine.getLineReader().getHistory(); if (history == null) { history = new DefaultHistory(); } else { try { history.save(); } catch (IOException e) { sqlLine.handleException(e); } } sqlLine.getLineReader() .setVariable(LineReader.HISTORY_FILE, get(HISTORY_FILE)); history.attach(sqlLine.getLineReader()); } }
public void setHistoryFile(String historyFile) { final String currentValue = get(HISTORY_FILE); if (Objects.equals(currentValue, historyFile) || Objects.equals(currentValue, Commands.expand(historyFile))) { return; } if (DEFAULT.equalsIgnoreCase(historyFile)) { set(HISTORY_FILE, DEFAULT); } else { propertiesMap.put(HISTORY_FILE, Commands.expand(historyFile)); } if (sqlLine != null && sqlLine.getLineReader() != null) { final History history = sqlLine.getLineReader().getHistory(); if (history != null) { try { history.save(); } catch (IOException e) { sqlLine.handleException(e); } } sqlLine.getLineReader() .setVariable(LineReader.HISTORY_FILE, get(HISTORY_FILE)); new DefaultHistory().attach(sqlLine.getLineReader()); } }
defaultHistory.save(); } catch (IOException e) { LOG.debug("Failed to save terminal history", e);
history.save();
history.save();
reader.getHistory().save(); } catch (IOException e1) {
callback); if (saveHistory) { fileHistory.save();
callback); if (saveHistory) { fileHistory.save();