Package jline.console.history

Examples of jline.console.history.FileHistory


        // We may not have the perms to read the history file...
        if( file.exists() && file.canRead() ) {
            // Override the FileHistory impl to trap failures due to the
            // user does not having write access to the history file.
            reader.setHistory(new FileHistory(file) {
                boolean failed = false;
                @Override
                public void flush() throws IOException {
                    if( !failed ) {
                        try {
View Full Code Here


  private void initHistory() {
    try {
      String historyPath = HOME_DIR + File.separator + HISTORY_FILE;
      if ((new File(HOME_DIR)).exists()) {
        reader.setHistory(new FileHistory(new File(historyPath)));
      } else {
        System.err.println("ERROR: home directory : '" + HOME_DIR +"' does not exist.");
      }
    } catch (Exception e) {
      System.err.println(e.getMessage());
View Full Code Here

    String historyPath = configDir + "/" + HISTORY_FILE_NAME;
    File accumuloDir = new File(configDir);
    if (!accumuloDir.exists() && !accumuloDir.mkdirs())
      log.warn("Unable to make directory for history at " + accumuloDir);
    try {
      final FileHistory history = new FileHistory(new File(historyPath));
      reader.setHistory(history);
      // Add shutdown hook to flush file history, per jline javadocs
      Runtime.getRuntime().addShutdownHook(new Thread() {
        @Override
        public void run() {
          try {
            history.flush();
          } catch (IOException e) {
            log.warn("Could not flush history to file.");
          }
        }
      });
View Full Code Here

  protected ConsoleReader createConsoleReader() {
    ConsoleReader consoleReader = null;
    try {
      consoleReader = new ConsoleReader();
      consoleReader.setPrompt(getPrompt());
      history = new FileHistory(getHistoryFile());
      consoleReader.setHistory(history);
    } catch (IOException e) {
      throw new IllegalStateException("Cannot create jline console reader", e);
    }
    return consoleReader;
View Full Code Here

        // We may not have the perms to read the history file...
        if( file.exists() && file.canRead() ) {
            // Override the FileHistory impl to trap failures due to the
            // user does not having write access to the history file.
            reader.setHistory(new FileHistory(file) {
                boolean failed = false;
                @Override
                public void flush() throws IOException {
                    if( !failed ) {
                        try {
View Full Code Here

            this.reader = new ConsoleReader(appName, in, out, null);
            this.reader.setExpandEvents(false);

            String userHome = System.getProperty("user.home");
            if (userHome != null && userHome.length()>0) {
                this.fileHistory = new FileHistory(new File(userHome, ShellSettings.HISTORY_FILE));
                this.reader.setHistory(fileHistory);
            } else {
                this.fileHistory = null;
            }
View Full Code Here

  protected ConsoleReader createConsoleReader() {
    ConsoleReader consoleReader = null;
    try {
      consoleReader = new ConsoleReader();
      consoleReader.setPrompt(getPrompt());
      history = new FileHistory(getHistoryFile(username));
      consoleReader.setHistory(history);
    } catch (IOException e) {
      throw new IllegalStateException("Cannot create jline console reader", e);
    }
    return consoleReader;
View Full Code Here

        ConsoleReader consoleReader = null;
        history = null;
        try {
            consoleReader = new ConsoleReader();
            consoleReader.setPrompt(getPrompt());
            history = new FileHistory(getHistoryFile(enteredUserName));
            consoleReader.setHistory(history);
        } catch (IOException e) {
            throw new IllegalStateException("Cannot create jline console reader", e);
        }
        return consoleReader;
View Full Code Here

            }
            catch (IOException ignored) {
                // can't create the file, so no history for you
            }
        }
        return file.canWrite() ? new FileHistory(file) : null;
    }
View Full Code Here

    private static MemoryHistory getHistory()
    {
        MemoryHistory history;
        File historyFile = new File(getUserHome(), ".presto_history");
        try {
            history = new FileHistory(historyFile);
        }
        catch (IOException e) {
            System.err.printf("WARNING: Failed to load history file (%s): %s. " +
                    "History will not be available during this session.%n",
                    historyFile, e.getMessage());
View Full Code Here

TOP

Related Classes of jline.console.history.FileHistory

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.