Package jline

Examples of jline.ConsoleReader


                try {
                    if(con == null) {
                        con = new ServerConnection(parser, out, in, kernel, deploymentFactory);
                    }
                    try {
                        dc.execute(new ConsoleReader(in, out), con, commandArgs);
                    } catch (DeploymentSyntaxException e) {
                        processException(out, e);
                    } catch (DeploymentException e) {
                        processException(out, e);
                    } catch (IOException e) {
View Full Code Here


            evaluateFileStatements(new BufferedReader(fileReader));
            return;
        }

        ConsoleReader reader = new ConsoleReader();
       
        if (!sessionState.batch)
        {
            reader.addCompletor(completer);
            reader.setBellEnabled(false);
           
            String historyFile = System.getProperty("user.home") + File.separator + HISTORYFILE;

            try
            {
                History history = new History(new File(historyFile));
                reader.setHistory(history);
            }
            catch (IOException exp)
            {
                sessionState.err.printf("Unable to open %s for writing %n", historyFile);
            }
        }
        else if (!sessionState.verbose) // if in batch mode but no verbose flag
        {
            sessionState.out.close();
        }

        cliClient.printBanner();

        String prompt;
        String line = "";
        String currentStatement = "";
        boolean inCompoundStatement = false;

        while (line != null)
        {
            prompt = (inCompoundStatement) ? "...\t" : getPrompt(cliClient);

            try
            {
                line = reader.readLine(prompt);
            }
            catch (IOException e)
            {
                // retry on I/O Exception
            }
View Full Code Here

    } catch (FileNotFoundException e) {
      System.err.println("Could not open input file for reading. (" + e.getMessage() + ")");
      System.exit(3);
    }

    ConsoleReader reader = new ConsoleReader();
    reader.setBellEnabled(false);
    // reader.setDebug(new PrintWriter(new FileWriter("writer.debug", true)));
    reader.addCompletor(getCommandCompletor());

    String line;
    final String HISTORYFILE = ".hivehistory";
    String historyFile = System.getProperty("user.home") + File.separator + HISTORYFILE;
    reader.setHistory(new History(new File(historyFile)));
    int ret = 0;

    String prefix = "";
    String curPrompt = prompt;
    while ((line = reader.readLine(curPrompt + "> ")) != null) {
      if (!prefix.equals("")) {
        prefix += '\n';
      }
      if (line.trim().endsWith(";") && !line.trim().endsWith("\\;")) {
        line = prefix + line;
View Full Code Here

            evaluateFileStatements(new BufferedReader(fileReader));
            return;
        }

        ConsoleReader reader = new ConsoleReader();
       
        if (!sessionState.batch)
        {
            reader.addCompletor(completer);
            reader.setBellEnabled(false);
           
            String historyFile = System.getProperty("user.home") + File.separator + HISTORYFILE;

            try
            {
                History history = new History(new File(historyFile));
                reader.setHistory(history);
            }
            catch (IOException exp)
            {
                sessionState.err.printf("Unable to open %s for writing %n", historyFile);
            }
        }
        else if (!sessionState.verbose) // if in batch mode but no verbose flag
        {
            sessionState.out.close();
        }

        printBanner();

        String prompt;
        String line = "";
        String currentStatement = "";
        boolean inCompoundStatement = false;

        while (line != null)
        {
            prompt = (inCompoundStatement) ? "...\t" : getPrompt(cliClient);

            try
            {
                line = reader.readLine(prompt);
            }
            catch (IOException e)
            {
                // retry on I/O Exception
            }
View Full Code Here

  private static class FakeCliDriver extends CliDriver {

    @Override
    protected ConsoleReader getConsoleReader() throws IOException {
      ConsoleReader reslt = new FakeConsoleReader();
      return reslt;
    }
View Full Code Here

    } catch (FileNotFoundException e) {
      System.err.println("Could not open input file for reading. (" + e.getMessage() + ")");
      return 3;
    }

    ConsoleReader reader =  getConsoleReader();
    reader.setBellEnabled(false);
    // reader.setDebug(new PrintWriter(new FileWriter("writer.debug", true)));
    for (Completor completor : getCommandCompletor()) {
      reader.addCompletor(completor);
    }

    String line;
    final String HISTORYFILE = ".hivehistory";
    String historyDirectory = System.getProperty("user.home");
    try {
      if ((new File(historyDirectory)).exists()) {
        String historyFile = historyDirectory + File.separator + HISTORYFILE;
        reader.setHistory(new History(new File(historyFile)));
      } else {
        System.err.println("WARNING: Directory for Hive history file: " + historyDirectory +
                           " does not exist.   History will not be available during this session.");
      }
    } catch (Exception e) {
      System.err.println("WARNING: Encountered an error while trying to initialize Hive's " +
                         "history file.  History will not be available during this session.");
      System.err.println(e.getMessage());
    }

    int ret = 0;

    String prefix = "";
    String curDB = getFormattedDb(conf, ss);
    String curPrompt = prompt + curDB;
    String dbSpaces = spacesForString(curDB);

    while ((line = reader.readLine(curPrompt + "> ")) != null) {
      if (!prefix.equals("")) {
        prefix += '\n';
      }
      if (line.trim().endsWith(";") && !line.trim().endsWith("\\;")) {
        line = prefix + line;
View Full Code Here

    }
    return ret;
  }

  protected ConsoleReader getConsoleReader() throws IOException{
    return new ConsoleReader();
  }
View Full Code Here

    if (!(initArgs(args))) {
      usage();
      return ERRNO_ARGS;
    }

    ConsoleReader reader = null;
    boolean runningScript = (getOpts().getScriptFile() != null);
    if (runningScript) {
      try {
        FileInputStream scriptStream = new FileInputStream(getOpts().getScriptFile());
        reader = getConsoleReader(scriptStream);
      } catch (Throwable t) {
        handleException(t);
        commands.quit(null);
        status = ERRNO_OTHER;
      }
    } else {
      reader = getConsoleReader(inputStream);
    }

    try {
      info(getApplicationTitle());
    } catch (Exception e) {
      // ignore
    }

    while (!exit) {
      try {
        // Execute one instruction; terminate on executing a script if there is an error
        if (!dispatch(reader.readLine(getPrompt())) && runningScript) {
          commands.quit(null);
          status = ERRNO_OTHER;
        }
      } catch (EOFException eof) {
        // CTRL-D
View Full Code Here

  }

  public ConsoleReader getConsoleReader(InputStream inputStream) throws IOException {
    if (inputStream != null) {
      // ### NOTE: fix for sf.net bug 879425.
      consoleReader = new ConsoleReader(inputStream, new PrintWriter(getOutputStream(), true));
    } else {
      consoleReader = new ConsoleReader();
    }

    // setup history
    ByteArrayInputStream historyBuffer = null;
View Full Code Here

   * @throws IOException
   */
  public static void main(@SuppressWarnings("unused") String args[])
  throws IOException {
    Configuration conf = new HBaseConfiguration();
    ConsoleReader reader = new ConsoleReader();
    reader.setBellEnabled(conf.getBoolean("hbaseshell.jline.bell.enabled",
      DEFAULT_BELL_ENABLED));
    Writer out = new OutputStreamWriter(System.out, "UTF-8");
    TableFormatterFactory tff = new TableFormatterFactory(out, conf);
    HelpCommand help = new HelpCommand(out, tff.get());
    help.printVersion();
    StringBuilder queryStr = new StringBuilder();
    String extendedLine;
    while ((extendedLine = reader.readLine(getPrompt(queryStr))) != null) {
      if (isEndOfCommand(extendedLine)) {
        queryStr.append(" " + extendedLine);
        long start = System.currentTimeMillis();
        Parser parser = new Parser(queryStr.toString(), out, tff.get());
        ReturnMsg rs = null;
View Full Code Here

TOP

Related Classes of jline.ConsoleReader

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.