node-args-parser
v0.0.1
Published
Command line arguments parser for Node.js
Downloads
6
Readme
node-args-parser
Node.js command line arguments parser.
Install the module
$ npm install node-args-parserUsage
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 2Will return:
{
"x": 1,
"y": 1,
}$ node ./script.js -f -r resourceWill return:
{
"f": true,
"r": "resource"
}if (args.f) {
console.log("flag 'f' is set")
}Tests
Run npm test
