node-args-parser

0.0.1 • Public • Published

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

Readme

Keywords

Package Sidebar

Install

npm i node-args-parser

Weekly Downloads

4

Version

0.0.1

License

MIT

Last publish

Collaborators

  • dipesh.singh