Package jline

Examples of jline.ConsoleReader


        setCompletor();
    }

    public void run() throws IOException {

        reader = new ConsoleReader();
        initJLine();
        // setup and start
        setup();

        running = true;
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)));

    List<SimpleCompletor> completors = new LinkedList<SimpleCompletor>();
    completors.add(new SimpleCompletor(new String[] {"set", "from", "create", "load", "describe",
        "quit", "exit"}));
    reader.addCompletor(new ArgumentCompletor(completors));

    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

          Transaction.startTransaction();
          consoleScope.put("autocommit", consoleScope, true);
          PersistableObject.enableSecurity(true);
         
          try {
            ConsoleReader reader = new ConsoleReader();
            StringBuffer sb = new StringBuffer();
            reader.setBellEnabled(false);
            System.out.println("Type \"help\" at the console for more information");
            do {
              String prompt = (sb.length() > 0) ? "   " : "js>"; // no prompt if we're on a multiline
              String line = reader.readLine(prompt);
              if(line == null){
                // in eclipse jline doesn't work, so we have to resort standard System.in
                char c;
                do{
                  c = (char) System.in.read();
View Full Code Here

  /** Main method */
  public static void main(String args[]) throws IOException {
    Configuration conf = new HBaseConfiguration();
    HClient client = new HClient(conf);
    ConsoleReader reader = new ConsoleReader();
    reader.setBellEnabled(conf.getBoolean("hbaseshell.jline.bell.enabled",
        DEFAULT_BELL_ENABLED));
    HelpManager help = new HelpManager();
    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());
        ReturnMsg rs = null;
View Full Code Here

  private void start() {
    System.out.println("Welcome to PlayOrm Command Line");
    System.out.println("Type 'help;' for help");
    System.out.println("Type 'exit;' to exit");
    try {
      ConsoleReader reader = new ConsoleReader();
      reader.setBellEnabled(false);
      String historyFile = System.getProperty("user.home")
          + File.separator + HISTORYFILE;
      History history = new History(new File(historyFile));
      reader.setHistory(history);

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

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

        line = reader.readLine(prompt);

        if (line == null)
          return;

        line = line.trim();
View Full Code Here

                    return ReturnCode.ILLEGAL_ARGS;
                }
                // Interactive
                mode = ExecMode.SHELL;
              //Reader is created by first loading "pig.load.default.statements" or .pigbootup file if available
                ConsoleReader reader = new ConsoleReaderWithParamSub(Utils.getCompositeStream(System.in, properties), new OutputStreamWriter(System.out), pigContext);
                reader.setDefaultPrompt("grunt> ");
                final String HISTORYFILE = ".pig_history";
                String historyFile = System.getProperty("user.home") + File.separator  + HISTORYFILE;
                reader.setHistory(new History(new File(historyFile)));
                ConsoleReaderInputStream inputStream = new ConsoleReaderInputStream(reader);
                grunt = new Grunt(new BufferedReader(new InputStreamReader(inputStream)), pigContext);
                grunt.setConsoleReader(reader);
                gruntCalled = true;
                grunt.run();
View Full Code Here

    private void loadScript(String script, boolean batch, boolean loadOnly, boolean illustrate,
                            List<String> params, List<String> files)
        throws IOException, ParseException {

        Reader inputReader;
        ConsoleReader reader;
        boolean interactive;

        mPigServer.getPigContext().setParams(params);
        mPigServer.getPigContext().setParamFiles(files);

        try {
            FetchFileRet fetchFile = FileLocalizer.fetchFile(mConf, script);
            String cmds = runPreprocessor(fetchFile.file.getAbsolutePath(), params, files);

            if (mInteractive && !batch) { // Write prompt and echo commands
                // Console reader treats tabs in a special way
                cmds = cmds.replaceAll("\t","    ");

                reader = new ConsoleReader(new ByteArrayInputStream(cmds.getBytes()),
                                           new OutputStreamWriter(System.out));
                reader.setHistory(mConsoleReader.getHistory());
                InputStream in = new ConsoleReaderInputStream(reader);
                inputReader = new BufferedReader(new InputStreamReader(in));
                interactive = true;
            } else { // Quietly parse the statements
                inputReader = new StringReader(cmds);
View Full Code Here

            System.setProperty("line.separator", sep);
            try {
                // just to force the loading of this class with the set line.separator
                // because ConsoleReader.CR is a constant and we need sometimes another value
                // not a big issue but keeping this as a workaround
                new ConsoleReader();
            } catch (final IOException ignored) {
                // no-op
            } finally {
                System.setProperty("line.separator", OS_LINE_SEP);
            }
View Full Code Here

        clean();

        try {
            final StreamManager streamManager = new StreamManager(out, err, lineSep);

            final ConsoleReader reader = new ConsoleReader(sin, streamManager.getSout());
            reader.addCompletor(new FileNameCompletor());
            reader.addCompletor(new SimpleCompletor(COMMANDS.keySet().toArray(new String[COMMANDS.size()])));
            // TODO : add completers

            String line;
            final StringBuilder builtWelcome = new StringBuilder("Apache OpenEJB ")
                .append(OpenEjbVersion.get().getVersion())
                .append("    build: ")
                .append(OpenEjbVersion.get().getDate())
                .append("-")
                .append(OpenEjbVersion.get().getTime())
                .append(lineSep);
            if (tomee) {
                builtWelcome.append(OS_LINE_SEP).append(PROPERTIES.getProperty(WELCOME_TOMEE_KEY));
            } else {
                builtWelcome.append(OS_LINE_SEP).append(PROPERTIES.getProperty(WELCOME_OPENEJB_KEY));
            }
            builtWelcome.append(lineSep).append(PROPERTIES.getProperty(WELCOME_COMMON_KEY));

            streamManager.writeOut(OpenEjbVersion.get().getUrl());
            streamManager.writeOut(builtWelcome.toString()
                .replace("$bind", bind)
                .replace("$port", Integer.toString(port))
                .replace("$name", NAME)
                .replace(OS_LINE_SEP, lineSep));

            while ((line = reader.readLine(prompt())) != null) {
                // exit simply let us go out of the loop
                // do we need a command for it?
                if (EXIT_COMMAND.equals(line)) {
                    break;
                }
View Full Code Here

        System.exit(1);
      }
    }
   
    HBaseConfiguration conf = new HBaseConfiguration();
    ConsoleReader reader = new ConsoleReader();
    System.setSecurityManager(new HQLSecurityManager());
    reader.setBellEnabled(conf.getBoolean("hbaseshell.jline.bell.enabled",
        DEFAULT_BELL_ENABLED));
    Writer out = new OutputStreamWriter(System.out, "UTF-8");
    TableFormatter tableFormater = new TableFormatterFactory(out, conf).get();
    if (MASTER_ADDRESS != null) {
      conf.set("hbase.master", MASTER_ADDRESS.substring(9, MASTER_ADDRESS.length()));
    }
    if (HTML_OPTION != null) {
      tableFormater = new HtmlTableFormatter(out);
    }

    HelpCommand help = new HelpCommand(out, tableFormater);
    if (args.length == 0 || !args[0].equals(String.valueOf(Shell.RELAUNCH_FLAG))) {
      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();

        HQLClient hql = new HQLClient(conf, MASTER_ADDRESS, out, tableFormater);
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.