Package jline

Examples of jline.ConsoleReader


 
  private static ConsoleReader reader = null;
 
  private static ConsoleReader getConsoleReader() throws IOException {
    if (reader == null)
      reader = new ConsoleReader();
    return reader;
  }
View Full Code Here


    if (!zookeeperAvailable()) {
      log.fatal("Zookeeper needs to be up and running in order to init. Exiting ...");
      return false;
    }
    if (ServerConfiguration.getSiteConfiguration().get(Property.INSTANCE_SECRET).equals(Property.INSTANCE_SECRET.getDefaultValue())) {
      ConsoleReader c = getConsoleReader();
      c.beep();
      c.printNewline();
      c.printNewline();
      c.printString("Warning!!! Your instance secret is still set to the default, this is not secure. We highly recommend you change it.");
      c.printNewline();
      c.printNewline();
      c.printNewline();
      c.printString("You can change the instance secret in accumulo by using:");
      c.printNewline();
      c.printString("   bin/accumulo " + org.apache.accumulo.server.util.ChangeSecret.class.getName() + " oldPassword newPassword.");
      c.printNewline();
      c.printString("You will also need to edit your secret in your configuration file by adding the property instance.secret to your conf/accumulo-site.xml. Without this accumulo will not operate correctly");
      c.printNewline();
    }
   
    UUID uuid = UUID.randomUUID();
   
    try {
View Full Code Here

    }

    // We lazily initialize this in case Readline.readline has been overridden in ruby (s_readline)
    protected static void initReadline(Ruby runtime, final ConsoleHolder holder) {
        try {
            holder.readline = new ConsoleReader();
        } catch (IOException ioe) {
            throw runtime.newIOErrorFromException(ioe);
        }
        holder.readline.setUseHistory(false);
        holder.readline.setUsePagination(true);
View Full Code Here

   
    CommandLine cl = null;
    String user = null;
    String passw = null;
    Instance instance = null;
    ConsoleReader reader = new ConsoleReader();
    try {
      cl = new BasicParser().parse(opts, args);
     
      if (cl.hasOption(zooKeeperInstance.getOpt()) && cl.getOptionValues(zooKeeperInstance.getOpt()).length != 2)
        throw new MissingArgumentException(zooKeeperInstance);
     
      user = cl.getOptionValue(usernameOption.getOpt());
      passw = cl.getOptionValue(passwOption.getOpt());
     
      if (cl.hasOption(zooKeeperInstance.getOpt())) {
        String[] zkOpts = cl.getOptionValues(zooKeeperInstance.getOpt());
        instance = new ZooKeeperInstance(zkOpts[0], zkOpts[1]);
      } else {
        instance = HdfsZooInstance.getInstance();
      }
     
      if (passw == null)
        passw = reader.readLine("Enter current password for '" + user + "'@'" + instance.getInstanceName() + "': ", '*');
      if (passw == null) {
        reader.printNewline();
        return;
      } // user canceled
     
      if (cl.getArgs().length != 0)
        throw new ParseException("Unrecognized arguments: " + cl.getArgList());
View Full Code Here

        this.out = out;
        this.err = err;

        // Initialize the JLine console input reader
        Writer writer = new OutputStreamWriter(out);
        reader = new ConsoleReader(in, writer);
        reader.setDefaultPrompt("groovy> ");

        // Add some completors to fancy things up
        reader.addCompletor(new CommandNameCompletor());
View Full Code Here

public class InputPrompt
{
    private ConsoleReader reader;

    public InputPrompt(final InputStream in, final Writer out) throws IOException {
        this.reader = new ConsoleReader(in, out);
    }
View Full Code Here

    public static String readLine(Object r) throws IOException {
        return ((ConsoleReader)r).readLine();
    }
   
    public static Object createJLineReader(final Shell shell) throws IOException {
        ConsoleReader reader = new ConsoleReader();
        fixCtrlC(reader);
        // Add a Ctrl-c listener
        reader.addTriggeredAction((char)3, new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                shell.bye();
                System.exit(0);
            }
        });
        reader.setBellEnabled(false);
        // TODO: write a Completor specific to this that can handle the individual command arguments
        List<Completor> completors = new LinkedList<Completor>();
//        completors.add(new SimpleCompletor(Shell.COMMANDS));
//        completors.add(new ICURICompletor(shell.node));
//        completors.add(new FileNameCompletor());
//        reader.addCompletor(new ArgumentCompletor(completors));
        reader.addCompletor(new TShellCompletor(shell));
        return reader;
    }
View Full Code Here

    private void loadScript(String script, boolean batch, boolean loadOnly,
                            List<String> params, List<String> files)
        throws IOException, ParseException {
       
        Reader inputReader;
        ConsoleReader reader;
        boolean interactive;
        
        try {
            String cmds = runPreprocessor(script, 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

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

    ConsoleReader reader = new ConsoleReader();
    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

        // run grunt interactive.
        String remainders[] = opts.getRemainingArgs();
        if (remainders == null) {
            // Interactive
            mode = ExecMode.SHELL;
            ConsoleReader reader = new ConsoleReader(System.in, new OutputStreamWriter(System.out));
            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

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.