Package jline.console

Examples of jline.console.ConsoleReader


  public TajoCli(TajoConf c, String [] args,
                 InputStream in, OutputStream out) throws Exception {
    this.conf = new TajoConf(c);
    this.sin = in;
    this.reader = new ConsoleReader(sin, out);
    this.sout = new PrintWriter(reader.getOutput());

    CommandLineParser parser = new PosixParser();
    CommandLine cmd = parser.parse(options, args);
View Full Code Here


    if (Main.debug) {
      out.println(blurQuery);
    }

    int maxWidth = 100;
    ConsoleReader reader = getConsoleReader();
    if (reader != null) {
      Terminal terminal = reader.getTerminal();
      maxWidth = terminal.getWidth() - 15;
      out.setLineLimit(terminal.getHeight() - 2);
    }
    long s = System.nanoTime();
    BlurResults blurResults = client.query(tablename, blurQuery);
View Full Code Here

  public void doit(PrintWriter out, Blur.Iface client, String[] args) throws CommandException, TException,
      BlurException {
    try {
      doitInternal(out, client, args);
    } finally {
      ConsoleReader reader = this.getConsoleReader();
      if (reader != null) {
        reader.setPrompt(Main.PROMPT);
      }
    }
  }
View Full Code Here

      cluster = Main.getCluster(client, "Invalid args: " + help());
    } else {
      cluster = args[1];
    }

    ConsoleReader reader = this.getConsoleReader();
    if (reader != null) {
      Terminal terminal = reader.getTerminal();
      _height = terminal.getHeight() - 2;
      _width = terminal.getWidth() - 2;
      try {
        reader.setPrompt("");
        reader.clearScreen();
      } catch (IOException e) {
        if (Main.debug) {
          e.printStackTrace();
        }
      }

      startCommandWatcher(reader, quit, help, this);
    }

    List<String> shardServerList = new ArrayList<String>(client.shardServerList(cluster));
    Collections.sort(shardServerList);
    Map<String, AtomicReference<Client>> shardClients = setupClients(shardServerList);

    String shardServerLabel = properties.getProperty(TOP_SHARD_SERVER_SHORTNAME);
    int longestServerName = Math.max(getSizeOfLongestKey(shardClients), shardServerLabel.length());

    StringBuilder header = new StringBuilder("%" + longestServerName + "s");
    for (int i = 1; i < labels.length; i++) {
      header.append(" %10s");
    }

    do {
      int lineCount = 0;
      StringBuilder output = new StringBuilder();
      if (quit.get()) {
        return;
      } else if (help.get()) {
        showHelp(output, labels, helpMap);
      } else {
        output.append(truncate(String.format(header.toString(), (Object[]) labels)) + "\n");
        lineCount++;
        SERVER:
        for (Entry<String, AtomicReference<Client>> e : new TreeMap<String, AtomicReference<Client>>(shardClients)
            .entrySet()) {
          String shardServer = e.getKey();
          AtomicReference<Client> ref = e.getValue();
          Map<String, Metric> metrics = getMetrics(shardServer, ref, keys);
          if (metrics == null) {
            String line = String.format("%" + longestServerName + "s*%n", shardServer);
            output.append(line);
            lineCount++;
            if (tooLong(lineCount)) {
              break SERVER;
            }
          } else {
            Object[] cols = new Object[labels.length];
            int c = 0;
            cols[c++] = shardServer;
            StringBuilder sb = new StringBuilder("%" + longestServerName + "s");

            for (int i = 1; i < labels.length; i++) {
              String mn = metricNames.get(labels[i]);
              Metric metric = metrics.get(mn);
              Map<String, Double> doubleMap = metric.getDoubleMap();
              Double value = doubleMap.get("oneMinuteRate");
              if (value == null) {
                value = doubleMap.get("value");
              }
              cols[c++] = humanize(value, sizes.contains(mn));
              sb.append(" %10s");
            }
            output.append(truncate(String.format(sb.toString(), cols)) + "\n");
            lineCount++;
            if (tooLong(lineCount)) {
              break SERVER;
            }
          }
        }
      }
      if (reader != null) {
        try {
          reader.clearScreen();
        } catch (IOException e) {
          if (Main.debug) {
            e.printStackTrace();
          }
        }
      }
      out.print(output.toString());
      out.flush();
      if (reader != null) {
        try {
          synchronized (this) {
            wait(3000);
          }
        } catch (InterruptedException e) {
          return;
        }
        Terminal terminal = reader.getTerminal();
        _height = terminal.getHeight() - 2;
        _width = terminal.getWidth() - 2;

        List<String> currentShardServerList = new ArrayList<String>(client.shardServerList(cluster));
        Collections.sort(currentShardServerList);
View Full Code Here

    }

    try {
      Blur.Iface client = BlurClient.getClient(cliShellOptions.getControllerConnectionString());
      if (cliShellOptions.isShell()) {
        ConsoleReader reader = new ConsoleReader();
        PrintWriter out = new PrintWriter(reader.getOutput());
        setConsoleReader(commands, reader);
        setPrompt(client, reader, cliShellOptions.getControllerConnectionString(), out);

        List<Completer> completors = new LinkedList<Completer>();

        // completors.add(new StringsCompleter(commands.keySet()));
        // completors.add(new FileNameCompleter());
        completors.add(new CommandCompletor(commands, client));

        for (Completer c : completors) {
          reader.addCompleter(c);
        }

        reader.setCompletionHandler(new ShowDiffsOnlyCompletionHandler());

        String line;
        try {
          while ((line = reader.readLine()) != null) {
            line = line.trim();
            // ignore empty lines and comments
            if (line.length() == 0 || line.startsWith("#")) {
              continue;
            }
View Full Code Here

  private static class ResetCommand extends Command {

    @Override
    public void doit(PrintWriter out, Blur.Iface client, String[] args) throws CommandException, TException,
        BlurException {
      ConsoleReader reader = getConsoleReader();
      if (reader != null) {
        try {
          reader.setPrompt("");
          reader.clearScreen();
        } catch (IOException e) {
          if (debug) {
            e.printStackTrace();
          }
          throw new CommandException(e.getMessage());
View Full Code Here

    if (row == null) {
      out.println("Row [" + rowId + "] not found.");
      return;
    }
    int maxWidth = 100;
    ConsoleReader reader = getConsoleReader();
    if (reader != null) {
      Terminal terminal = reader.getTerminal();
      maxWidth = terminal.getWidth() - 15;
      out.setLineLimit(terminal.getHeight() - 2);
    }
    format(out, row, maxWidth);
  }
View Full Code Here

        return null;
    }

    private boolean confirm(CommandSession session) throws IOException {
        for (;;) {
            ConsoleReader reader = (ConsoleReader) session.get(".jline.reader");
            String msg = "You are about to perform a start/stop/refresh load test on bundles.\nDo you wish to continue (yes/no): ";
            String str = reader.readLine(msg);
            if ("yes".equalsIgnoreCase(str)) {
                return true;
            }
            if ("no".equalsIgnoreCase(str)) {
                return false;
View Full Code Here

        if (level == null) {
            System.out.println("Level " + bsl.getStartLevel());
        }
        else if ((level < 50) && (bsl.getStartLevel() > 50) && !force){
            for (;;) {
                ConsoleReader reader = (ConsoleReader) session.get(".jline.reader");
                String msg = "You are about to designate bundle as a system bundle.  Do you wish to continue (yes/no): ";
                String str = reader.readLine(msg);
                if ("yes".equalsIgnoreCase(str)) {
                    bsl.setStartLevel(level);
                    break;
                } else if ("no".equalsIgnoreCase(str)) {
                    break;
View Full Code Here

        this.consoleInput = new ConsoleInputStream();
        this.session = processor.createSession(this.consoleInput, this.out, this.err);
        this.session.put("SCOPE", "shell:osgi:*");
        this.closeCallback = closeCallback;

        reader = new ConsoleReader(null,
                                   this.consoleInput,
                                   this.out,
                                   this.terminal,
                                   encoding);

View Full Code Here

TOP

Related Classes of jline.console.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.