Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

args-parser

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

args-parser

Straight-forward node.js arguments parser

  • 1.3.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
34K
decreased by-8.31%
Maintainers
1
Weekly downloads
 
Created
Source

args-parser

Straight-forward node.js arguments parser.

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

{
  "careful": true,
  "dangerous": true,
  "tomatoes": 3,
  "tonight": true,
  "key": "ek=="
}

How to use it?

$ npm install args-parser

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 given argument and a value if it's found an = sign (true otherwise).

Consider this command:

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

Will return:

{
  "careful": true,
  "dangerous": true,
  "tomatoes": 3,
  "tonight": true,
  "key": "ek=="
}

So then you can easily check what you need:

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

Keywords

FAQs

Package last updated on 08 Jul 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc