node-args-parser
v0.0.1
Published
Command line arguments parser for Node.js
Downloads
5
Readme
node-args-parser
Node.js command line arguments parser.
Install the module
$ npm install node-args-parser
Usage
Require the module and pass it the process.argv
arguments array.
const args = require("node-args-parser")(process.argv)
console.info(args)
An object
is returned having a key for each argument given.
For example:
$ node ./script.js -x 1 -y 2
Will return:
{
"x": 1,
"y": 1,
}
$ node ./script.js -f -r resource
Will return:
{
"f": true,
"r": "resource"
}
if (args.f) {
console.log("flag 'f' is set")
}
Tests
Run npm test