JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 35718
  • Score
    100M100P100Q140164F
  • License Apache-2.0

Straight-forward node.js arguments parser

Package Exports

  • args-parser

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (args-parser) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

args-parser

Straight-forward node.js arguments parser.

Get the module

$ npm install args-parser

How to use it?

args(arguments)

Simply call the module passing it an arguments array such as process.argv:

const args = require("args-parser")(process.argv)

console.info(args)

The returned value is an Object having a key for each argument given, and eventually a value if it's found an = sign.

Considering that simple command:

$ node ./script.js careful -dangerous --tomatoes=3 --tonight

Will return:

{
   "careful": true,
   "dangerous": true,
   "tomatoes": 3,
   "tonight": true
}

So then you can easily check what you need:

if (args.careful) {
    // Do something
}