1.0.0 • Published 8 years ago

wrq-argv-parser v1.0.0

Weekly downloads
1
License
ISC
Repository
-
Last release
8 years ago

argvParser

Module for parse argv options.

Example:

var argvParser = require('argv-parser');
var argv = [
  'node',
  'index.js',
  '-f',
  'a.js',
  '-r',
  '-watch',
  1,
  2,
  3
];
var options = {
  '-f': 1, // count of the option parameters
  '-r': 0,
  '-watch': 'multiple', //include all following parameters until finding the next option
};
var ret = argvParser(argv, options);
console.log(ret);

Output:

{
  '-f': ['a.js'],
  '-r': [],
  '-watch': [1, 2, 3]
}

If your options are not starting with '-' but another character like "--",try argvParser(argv, options, '--').