Standard input management module for NodeJS
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
.gitignore
README.md
main.js
package.json
tests.js

README.md

Module for input management with nodejs.

This is a very young project. Use it at your own risk.

Install

To install the most recent release from npm, run:

npm install in

Use

You can do many things with this module

Read standard input at once

    var input = require('in');
    input.read(function(data){
        console.log(data);
    });

Parse Unix-like command line options

    var input = require('in');
    var ops = input.getopt({
        'check': {key: 'c', args: 2},
        'map': {key: 'm'},
        'kaka': {key: 'k', args: 2},
        'ooo': {key: 'o'}
    });
    console.log(ops);

If you run the previous example with the command

node pruebas.js -c 23 45 88 --map -k 23 44 cosa

Program output will be:

{ check: { args: [ '23', '45' ] },
  args: [ '88', 'cosa' ],
  map: true,
  kaka: { args: [ '23', '44' ] } }

So you can check options:

    if(ops.map){
        // Your action
    }
    if(ops.kaka){
        // Your action, using ops.kaka[0] or ops.kaka[1] or...
    }