Reputation: 21795
I would like to see paging when I have long outputs in node js REPL.
Is that possible, how?
Upvotes: 2
Views: 197
Reputation: 20730
Vorpal.js is a Node module that looks like it would do the trick. Vorpal turns your Node app into an interactive CLI, and supports extensions including an implementation of the less
command in Node.
Something like this would work:
var vorpal = require('vorpal')();
var less = require('vorpal-less');
vorpal
.catch('[commands...]')
.action(function (args, cb) {
args.commands = args.commands || [];
var cmd = args.commands.join(' ');
var res;
try {
res = eval(cmd);
} catch(e) {
res = e;
}
this.log(res);
cb();
});
vorpal
.delimiter('myrepl>')
.show();
This will turn your application into a REPL within the context of your app, which can also accept the less
command:
$ node myrepl.js
myrepl> 6 * 6 | less
36
: (less prompt)
Disclaimer: I wrote Vorpal
Upvotes: 1