0.0.1 • Published 7 years ago

node-args-parser v0.0.1

Weekly downloads
6
License
MIT
Repository
github
Last release
7 years ago

node-args-parser

Build Status Coverage Status

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