@Override public void execute(final List<String> args, final PrintWriter terminal) { CliCmdUtil.ensureArgCountBounds(args, 0, 0, HELP); throw new EndOfFileException(); } }
/** * Attempt to read a logical line of input from the user. Can span multiple physical lines, as * long as all but the last end with '\\'. * * @return The parsed, logical line. * @throws EndOfFileException If there is no more input available from the user. */ private String readLine() { while (true) { try { final String result = terminal.readLine(); // A 'dumb' terminal (the kind used at runtime if a 'system' terminal isn't available) will // return null on EOF and user interrupt, instead of throwing the more fine-grained // exceptions. This null-check helps ensure that, upon encountering EOF, even a 'dumb' // terminal will be able to exit intelligently. if (result == null) { throw new EndOfFileException(); } else { return result.trim(); } } catch (final UserInterruptException exception) { // User hit ctrl-C, just clear the current line and try again. terminal.writer().println("^C"); terminal.flush(); } } }
/** * Read a codepoint from the terminal. * * @return the character, or -1 if an EOF is received. */ public int readCharacter() { if (!pushBackChar.isEmpty()) { return pushBackChar.pop(); } try { int c = NonBlockingReader.READ_EXPIRED; int s = 0; while (c == NonBlockingReader.READ_EXPIRED) { c = reader.read(100L); if (c >= 0 && Character.isHighSurrogate((char) c)) { s = c; c = NonBlockingReader.READ_EXPIRED; } } return s != 0 ? Character.toCodePoint((char) s, (char) c) : c; } catch (ClosedException e) { throw new EndOfFileException(e); } catch (IOException e) { throw new IOError(e); } }
throw new EndOfFileException();
throw new EndOfFileException(); throw new EndOfFileException(); return finishBuffer(); case EOF: throw new EndOfFileException(); case INTERRUPT: throw new UserInterruptException(buf.toString());