In short: I want to create a CLI for the development daemon. Daemon displays various information in stdout, and I want to pass this information to the user in a screen area in a scrollable way. I struggle to be happy. A simple prototype below that buffers stdout, so the information never completes.
var blessed = require('blessed'); var screen = blessed.screen(), body = blessed.box({ top: 1, left: 0, width: '100%', height: '99%' }), statusbar = blessed.box({ top: 0, left: 0, width: '100%', height: 1, style: { fg: 'white', bg: 'blue' } }); screen.append(statusbar); screen.append(body); screen.key(['escape', 'q', 'C-c'], function(ch, key) { return process.exit(0); }); function status(text) { statusbar.setContent(text); screen.render(); } function log(text) { body.insertLine(0, text); screen.render(); } status('TEST'); var spawn = require('child_process').spawn; yes = spawn('yes', ['it is']); ls.stdout.on('data', function (data) { log(data.toString()); }); ls.stderr.on('data', function (data) { log(data.toString()); });
user1190411
source share