Refine search
public String interact(String textToPrompt) { try { return reader.readLine(textToPrompt); } catch (IOException e) { throw new RuntimeException(e); } }
protected void setupConsoleReader() throws IOException { reader = new ConsoleReader(); reader.setExpandEvents(false); reader.setBellEnabled(false); for (Completer completer : getCommandCompleter()) { reader.addCompleter(completer); } setupCmdHistory(); }
public static void main(String[] args) { try { ConsoleReader reader = new ConsoleReader(); reader.setPrompt("prompt> "); // set up the completion CliCommands commands = new CliCommands(reader); CommandLine cmd = new CommandLine(commands); reader.addCompleter(new PicocliJLineCompleter(cmd.getCommandSpec())); // start the shell and process input until the user quits with Ctl-D String line; while ((line = reader.readLine()) != null) { ArgumentList list = new WhitespaceArgumentDelimiter().delimit(line, line.length()); CommandLine.run(commands, list.getArguments()); } } catch (Throwable t) { t.printStackTrace(); } } }
@Override protected ConsoleReader createConsoleReader() { ConsoleReader consoleReader = super.createConsoleReader(); consoleReader.setHistory(gfshHistory); terminal = consoleReader.getTerminal(); return consoleReader; }
private static String readLine(ConsoleReader reader, String prompt) throws IOException { String earlierLine = reader.getCursorBuffer().toString(); String readLine; try { readLine = reader.readLine(prompt); } catch (IndexOutOfBoundsException e) { if (earlierLine.length() == 0) { reader.println(); readLine = LINE_SEPARATOR; reader.getCursorBuffer().cursor = 0; } else { readLine = readLine(reader, prompt); } } return readLine; }
/** * Possible states in which the current readline operation may be in. */ private static enum State { /** * The user is just typing away */ NORMAL, /** * In the middle of a emacs seach */ SEARCH, FORWARD_SEARCH, /** * VI "yank-to" operation ("y" during move mode) */ VI_YANK_TO, /** * VI "delete-to" operation ("d" during move mode) */ VI_DELETE_TO, /** * VI "change-to" operation ("c" during move mode) */ VI_CHANGE_TO }
consoleReader = new ConsoleReader(); consoleReader.setExpandEvents( false ); consoleReader.addCompleter( new ConsoleCommandCompleter( this ) );
try { final FileHistory history = new FileHistory(new File(historyPath)); reader.setHistory(history); reader.setHandleUserInterrupt(true); reader.removeCompleter(userCompletor); reader.addCompleter(userCompletor); reader.setPrompt(getDefaultPrompt()); input = reader.readLine(); if (input == null) { reader.println(); return exitCode; } catch (UserInterruptException uie) { reader.println(); reader.flush();
consoleReader = new ConsoleReader(inputStreamAppendedNewline, getErrorStream()); consoleReader.setCopyPasteDetection(true); // jline will detect if <tab> is regular character } else { consoleReader = new ConsoleReader(getInputStream(), getErrorStream()); consoleReader.setExpandEvents(false); consoleReader.setHistory(this.history); } else { consoleReader.setHistoryEnabled(false); consoleReader.addCompleter(new BeeLineCompleter(this)); return consoleReader;
@Override public void start(Environment environment) throws IOException { errorPrintStream = new PrintStream(errorStream, true); String user = environment.getEnv().get(Environment.ENV_USER); if (Strings.isNullOrEmpty(user)) { user = "unknown"; } try { // Use our RemoteTerminal which does not depends on the platform. terminal = new RemoteTerminal(true); terminal.init(); } catch (Exception e) { LOGGER.warn("Error during terminal detection, falling back to unsupported terminal"); LOGGER.debug(DETAILS_MESSAGE, e); terminal = new UnsupportedTerminal(); } consoleReader = new ConsoleReader(inputStream, outputStream, terminal); // Disable jline shutdownhook to avoid exception at application shutdown jline.internal.Configuration.getString("jline.shutdownhook", "false"); consoleReader.addCompleter(new StringsCompleter(commandRegistry.getCommandList())); consoleReader.setCompletionHandler(new CandidateListCompletionHandler()); consoleReader.setPrompt(user + "@" + application.getId() + "$ "); consoleReader.setHandleUserInterrupt(false); consoleReader.setHistoryEnabled(true); ses = new SubjectAwareExecutorService(Executors.newSingleThreadExecutor()); ses.submit(this); }
ConsoleReader reader = new ConsoleReader(); reader.setBellEnabled(false); String prefix = ""; String curPrompt = prompt; while ((line = reader.readLine(curPrompt + "> ")) != null) { if (!prefix.equals("")) { //NOSONAR prefix += '\n';
/** * Setup console-reader to capture Shell output */ @Override protected ConsoleReader createConsoleReader() { try { output = new ByteArrayOutputStream(1024 * 10); PrintStream sysout = new PrintStream(output); setGfshOutErr(sysout); return new ConsoleReader(new FileInputStream(FileDescriptor.in), sysout); } catch (IOException e) { throw new RuntimeException(e); } } }
this.reader = new ConsoleReader(); ShellOptionsJC options = new ShellOptionsJC(); JCommander jc = new JCommander(); .addShutdownHook(new Thread(() -> reader.getTerminal().setEchoEnabled(true))); password = reader.readLine("Password: ", '*');
public void start(int initialPort) throws Exception { ConsoleReader console = new ConsoleReader(); console.getTerminal().setEchoEnabled(false); console.setPrompt("\u001B[32menkan\u001B[0m> "); History history = new FileHistory(new File(System.getProperty("user.home"), ".enkan_history")); console.setHistory(history); CandidateListCompletionHandler handler = new CandidateListCompletionHandler(); console.setCompletionHandler(handler); consoleHandler = new ConsoleHandler(console); if (initialPort > 0) { consoleHandler.connect(initialPort); } clientThread.execute(consoleHandler); clientThread.shutdown(); }
ConsoleReader reader = new ConsoleReader(); reader.setHistory(new FileHistory(new File(Configuration.getUserHome(), String.format(".jline-%s.%s.history", mainClass, historyFileName)))); reader.setHistory(new FileHistory(new File(Configuration.getUserHome(), String.format(".jline-%s.history", mainClass)))); reader.addCompleter(new ArgumentCompleter(completorList)); if (reader.getHistory() instanceof PersistentHistory) { ((PersistentHistory) reader.getHistory()).flush();
public JLineCliConsole(InputStream in, PrintStream out, Log logger, Completer completer, String prompt) { try { consoleReader = new ConsoleReader(in, out); consoleReader.setBellEnabled(false); consoleReader.setPrompt(prompt + "> "); this.logger = logger; consoleReader.addCompleter(completer); } catch (IOException ex) { throw new RuntimeException("Unable to create reader to read commands.", ex); } }
public static String[] getRawAnsiSettings() throws IOException { ConsoleReader reader = new ConsoleReader(); return new String[] { "Width: " + reader.getTerminal().getWidth(), "Height: " + reader.getTerminal().getHeight(), "Ansi: " + reader.getTerminal().isAnsiSupported(), "Echo: " + reader.getTerminal().isEchoEnabled(), "Supported: " + reader.getTerminal().isSupported() }; }
private void initializeConsoleReader() { this.consoleReader.setHistoryEnabled(true); this.consoleReader.setBellEnabled(false); this.consoleReader.setExpandEvents(false); this.consoleReader.addCompleter(new CommandCompleter(this.consoleReader, this.argumentDelimiter, this.commandRunner)); this.consoleReader.setCompletionHandler(new CandidateListCompletionHandler()); }
public Terminal(Configuration configuration) { try { this.configuration = configuration; jline.TerminalFactory.configure("auto"); reader = new ConsoleReader(); reader.setHistory(new MemoryHistory()); reader.addCompleter(new ArgumentCompleter(selectCompleters())); } catch (IOException ex) { throw new RuntimeException(ex); } }