CliCommands(ConsoleReader reader) { this.reader = reader; out = new PrintWriter(reader.getOutput()); }
public GreysConsole(InetSocketAddress address) throws IOException { this.console = initConsoleReader(); this.history = initHistory(); this.out = console.getOutput(); this.history.moveToEnd(); this.console.setHistoryEnabled(true); this.console.setHistory(history); this.console.setExpandEvents(false); this.socket = connect(address); // 关闭会话静默 disableSilentOfSession(); // 初始化自动补全 initCompleter(); this.isRunning = true; activeConsoleReader(); socketWriter.write("version\n"); socketWriter.flush(); loopForWriter(); }
public void run() { while (!interrupted()) { try { Writer out = getOutput(); out.write(fullPrompt); out.flush(); sleep(3); } catch (IOException e) { return; } catch (InterruptedException e) { return; } } } };
public void stop(String message) { if (null != console) { PrintWriter pw = new PrintWriter(console.getOutput()); pw.println(message); pw.flush(); } stop(); }
private synchronized IASCIITable tbl() { if (asciiTable == null) { asciiTable = new SimpleASCIITableImpl(new PrintWriter(console.getOutput())); } return asciiTable; }
private void printEvalException(EvalException e) throws IOException { reader.getOutput().append("ERROR: ").append(e.getMessage()).append("\n"); if (e.getCause() != null) { reader.getOutput().write(Throwables.getStackTraceAsString(e.getCause())); } PrintWriter printWriter = new PrintWriter(reader.getOutput()); e.printRStackTrace(printWriter); printWriter.flush(); reader.getOutput().flush(); }
public void stop(String message) { if (null != console) { PrintWriter pw = new PrintWriter(console.getOutput()); pw.println(message); pw.flush(); } stop(); }
private synchronized IASCIITable tbl() { if (asciiTable == null) { asciiTable = new SimpleASCIITableImpl(new PrintWriter(console.getOutput())); } return asciiTable; }
public JLineConsole(String programName) throws IOException { this.console = newConsoleReader(programName); this.formatter = new Formatter(console.getOutput()); this.console.setCopyPasteDetection(true); }
private Object eval(Object line) throws StopInputException, IOException { try { Object ret = Compiler.eval(line); writer.flush(); reader.getOutput().flush(); return ret; } catch (Throwable t) { lastError.set(t); printStackTrace(t); return null; } }
public synchronized void stashLine() { this.stashed = reader.getCursorBuffer().copy(); try { reader.getOutput().write("\u001b[1G\u001b[K"); reader.flush(); } catch (IOException e) { // ignore } }
KGMSConsole(InputStream in, OutputStream out, ManagedChannel channel) throws IOException { this.console = new ConsoleReader(in, out); this.outPrinter = new PrintWriter(console.getOutput()); this.channel = channel; ResponseListener responseListener = new ResponseListener(new ArrayBlockingQueue<>(1)); this.userManagementClient = new UserManagementClient(KGMSConsoleGrpc.newStub(channel), responseListener); this.commandBus = initialiseCommandBus(); registerShutdownHook(); }
public static void main(String[] args) throws Exception { ConsoleReader reader = new ConsoleReader(); reader.setPrompt("> "); PrintWriter out = new PrintWriter(reader.getOutput()); out.println(banner()); Environment env = new Environment(); while (!env.isHalted()) { String line = reader.readLine(); if (line == null) break; String output = eval(env, line); out.println(output); out.flush(); } }
protected CliContext(String line, App app, ConsoleReader console, CliSession session, boolean rawPrint) { super(app); this.session = session; this.parser = new CommandLineParser(line); this.evaluatorCache = app.cache(); this.console = $.NPE(console); this.pw = new PrintWriter(console.getOutput()); this.rawPrint = rawPrint; this.handler = app.cliDispatcher().handler(command()); this.preparsedOptionValues = new HashMap<String, String>(); this.saveLocal(); }
protected CliContext(String line, App app, ConsoleReader console, CliSession session, boolean rawPrint) { super(app); this.session = session; this.parser = new CommandLineParser(line); this.evaluatorCache = app.cache(); this.console = $.NPE(console); this.pw = new PrintWriter(console.getOutput()); this.rawPrint = rawPrint; this.handler = app.cliDispatcher().handler(command()); this.preparsedOptionValues = new HashMap<String, String>(); this.saveLocal(); }
public void printBar(ProgressGauge progressGauge) { PrintStream os = new PrintStream(new WriterOutputStream(rawPrint ? pw : console.getOutput())); String label = app().config().i18nEnabled() ? i18n("act.progress.capFirst") : "Progress"; ProgressBar pb = new ProgressBar(label, progressGauge.maxHint(), 200, os, ProgressBarStyle.UNICODE_BLOCK); pb.start(); while (!progressGauge.isDone()) { pb.maxHint(progressGauge.maxHint()); pb.stepTo(progressGauge.currentSteps()); Thread.yield(); flush(); } pb.stepTo(pb.getMax()); pb.stop(); }
public void printBar(ProgressGauge progressGauge) { PrintStream os = new PrintStream(new WriterOutputStream(rawPrint ? pw : console.getOutput())); String label = app().config().i18nEnabled() ? i18n("act.progress.capFirst") : "Progress"; ProgressBar pb = new ProgressBar(label, progressGauge.maxHint(), 200, os, ProgressBarStyle.UNICODE_BLOCK); pb.start(); while (!progressGauge.isDone()) { pb.maxHint(progressGauge.maxHint()); pb.stepTo(progressGauge.currentSteps()); Thread.yield(); flush(); } pb.stepTo(pb.getMax()); pb.stop(); }