Capture text piped from stdin
Install the package using NPM:
npm install --save nutty-body
//Import nutty
var nutty = require('nutty');
var nutty_body = require('nutty-body');
//Set the CLI name
nutty.set('name', 'stdin');
//Set the CLI description
nutty.set('description', 'My test app');
//Set the CLI version
nutty.set('version', '1.0.0');
//Parse the body
nutty.use(nutty_body({ limit: 1024 }));
//Use a middleware
nutty.use(function(args, next)
{
//Display in console
console.log('Data from stdin: ');
console.log(args.body);
});
//Run the CLI
nutty.run();
var nutty_body = require('nutty-body');
Returns a middleware to be used with nutty.use
(see the nutty.use documentation). The options argument must be an object with the following settings:
limit
: anumber
with the maximum data size that can be piped fromstdin
. Default is1024
.
MIT LICENSE.