final ParsedLine parsedLine = reader.getParsedLine(); final String[] parsedArgs = parsedLine.words().toArray(new String[parsedLine.words().size()]); commandProcessor.process(parsedArgs);
/** * Print confirmation message and get response * * @param message message to print * @return response read from terminal */ public String read(String message) { LineReader lr = SshShellCommandFactory.SSH_THREAD_CONTEXT.get().getLineReader(); if (message != null) { lr.getTerminal().writer().println(message); } lr.readLine(); if (lr.getTerminal() instanceof AbstractPosixTerminal) { lr.getTerminal().writer().println(); } return lr.getParsedLine().line(); }
@Override public Input readInput() { try { AttributedString prompt = promptProvider.getPrompt(); lineReader.readLine(prompt.toAnsi(lineReader.getTerminal())); } catch (UserInterruptException e) { if (e.getPartialLine().isEmpty()) { throw new ExitRequest(1); } else { return Input.EMPTY; } } return new ParsedLineInput(lineReader.getParsedLine()); } }
private CharSequence readCommand(AtomicBoolean reading) throws UserInterruptException { CharSequence command = null; reading.set(true); try { reader.readLine(getPrompt(), getRPrompt(), maskingCallback, null); ParsedLine pl = reader.getParsedLine(); if (pl instanceof ParsedLineImpl) { command = ((ParsedLineImpl) pl).program(); } else if (pl != null) { command = pl.line(); } else { command = reader.getBuffer().toString(); } } catch (EndOfFileException e) { command = null; } catch (UserInterruptException e) { command = ""; // Do nothing } catch (Throwable t) { ShellUtil.logException(this, t); } finally { reading.set(false); } return command; }
private CharSequence readCommand(AtomicBoolean reading) throws UserInterruptException { CharSequence command = null; reading.set(true); try { reader.readLine(getPrompt(), getRPrompt(), maskingCallback, null); ParsedLine pl = reader.getParsedLine(); if (pl instanceof ParsedLineImpl) { command = ((ParsedLineImpl) pl).program(); } else if (pl != null) { command = pl.line(); } else { command = reader.getBuffer().toString(); } } catch (EndOfFileException e) { command = null; } catch (UserInterruptException e) { command = ""; // Do nothing } catch (Throwable t) { ShellUtil.logException(this, t); } finally { reading.set(false); } return command; }
reading.set(false); ParsedLine parsedLine = reader.getParsedLine(); if (parsedLine == null) { throw new EndOfFileException();