@Override public void run() { History h = reader.getHistory(); if (h instanceof FileHistory) { try { ((FileHistory) h).flush(); } catch (IOException e) { System.err.println("WARNING: Failed to write command history file: " + e.getMessage()); } } } });
public boolean history(String line) { Iterator hist = beeLine.getConsoleReader().getHistory().entries(); String[] tmp; while(hist.hasNext()){ tmp = hist.next().toString().split(":", 2); tmp[0] = Integer.toString(Integer.parseInt(tmp[0]) + 1); beeLine.output(beeLine.getColorBuffer().pad(tmp[0], 6) .append(":" + tmp[1])); } return true; }
@Override public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws IOException { if (cl.hasOption(clearHist.getOpt())) { shellState.getReader().getHistory().clear(); } else { Iterator<Entry> source = shellState.getReader().getHistory().entries(); Iterator<String> historyIterator = Iterators.transform(source, input -> String.format("%d: %s", input.index() + 1, input.value())); shellState.printLines(historyIterator, !cl.hasOption(disablePaginationOpt.getOpt())); } return 0; }
if (reader.getHistory() instanceof PersistentHistory) { ((PersistentHistory) reader.getHistory()).flush();
public History getHistory() { if (consoleReader != null) { return consoleReader.getHistory(); } return null; }
@Override public void run() { try { ((FileHistory) console.getHistory()).flush(); } catch (Exception e) { e.printStackTrace(); } }
@Override public void run() { History h = reader.getHistory(); if (h instanceof FileHistory) { try { ((FileHistory) h).flush(); } catch (IOException e) { System.err.println("WARNING: Failed to write command history file: " + e.getMessage()); } } } }));
@Override protected boolean executeCommand(Context context, String[] args) { for (int i = 0; i < consoleReader.getHistory().size(); i++) { System.out.println(String.format("%4d %s", i + 1, consoleReader.getHistory().get(i))); } return true; } }
@Override public void run() { History h = reader.getHistory(); if (h instanceof FileHistory) { try { ((FileHistory) h).flush(); } catch (IOException e) { System.err.println("WARNING: Failed to write command history file: " + e.getMessage()); } } } });
@Override public void run() { History h = reader.getHistory(); if (h instanceof FileHistory) { try { ((FileHistory) h).flush(); } catch (IOException e) { System.err.println("WARNING: Failed to write command history file: " + e.getMessage()); } } } }));
@Override protected boolean executeCommand(Context context, String[] args) { for (int i = 0; i < consoleReader.getHistory().size(); i++) { System.out.println(String.format("%4d %s", i + 1, consoleReader.getHistory().get(i))); } return true; } }
@Override public void run() { try { ((FileHistory) consoleReader.getHistory()).flush(); } catch (IOException ex) { } } });
private void loadHistory() { if (HISTORY_FILE != null && HISTORY_FILE.exists()) { try { try (LineNumberReader reader = new LineNumberReader(new FileReader(HISTORY_FILE))) { History history = consoleReader.getHistory(); String line; while ((line = reader.readLine()) != null) { history.add(line); } } } catch (IOException ignored) { System.err.println("ERROR: could not load history file from ~/.eureka_history"); } } }
public void run() { try { if (reader.getHistory() instanceof FileHistory) { ((FileHistory) reader.getHistory()).flush(); } reader.getTerminal().restore(); } catch (Exception e) { // do nothing } } });
@Override public void run() { History h = consoleReader.getHistory(); if (h instanceof FileHistory) { try { ((FileHistory) h).flush(); } catch (IOException e) { error(e); } } } }));
@Override public void run() { History h = consoleReader.getHistory(); if (h instanceof FileHistory) { try { ((FileHistory) h).flush(); } catch (IOException e) { error(e); } } } }));
public boolean history(String line) { Iterator hist = beeLine.getConsoleReader().getHistory().entries(); String[] tmp; while(hist.hasNext()){ tmp = hist.next().toString().split(":", 2); tmp[0] = Integer.toString(Integer.parseInt(tmp[0]) + 1); beeLine.output(beeLine.getColorBuffer().pad(tmp[0], 6) .append(":" + tmp[1])); } return true; }
public boolean history(String line) { Iterator hist = beeLine.getConsoleReader().getHistory().entries(); int index = 1; while(hist.hasNext()){ beeLine.output(beeLine.getColorBuffer().pad(index + ".", 6) .append(hist.next().toString())); } return true; }
public boolean history(String line) { Iterator hist = beeLine.getConsoleReader().getHistory().entries(); int index = 1; while(hist.hasNext()){ beeLine.output(beeLine.getColorBuffer().pad(index + ".", 6) .append(hist.next().toString())); } return true; }
@Test public void testHistory() throws IOException{ ConsoleReader console= new ConsoleReader(); //History history= new History(new File(System.getProperty("user.home") + File.separator + ".asciigenome_history")); History history= new MemoryHistory(); history.add("foobar"); history.add("baz"); console.setHistory(history); System.out.println(console.getHistory()); console.close(); }