Socket
Book a DemoInstallSign in
Socket

argv-options

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

argv-options

opinionated argv options parser

latest
Source
npmnpm
Version
1.0.0
Version published
Maintainers
1
Created
Source

argv-options

npm Travis

argv-options subjectively parses your argv options, i.e., it makes assumptions about how your CLI is designed to keep the API simple. It expects your argv object to be supplied in the format of -p foo --param bar, i.e., simple key-value arguments that may be aliased (using --).

API

parseOptions(argv, options)

This method will return the parsed options in a key-value based object, including all found options and their respective aliases. The following arugments are mandatory:

  • argv The arguments array, as space-split array of all parameters. In your average usage case, passing process.argv.slice(2) will do.
  • options The possible options, as object:
{
  "p": {
    "optional": false,
    "alias": "param"
  },

  "a": {
    "optional": true,
    "alias": "argument"
  }
}

Parameters are required (optional is false) by default. Alternatively, for more convenient use, aliases may be specified by using the key's value:

{
  "p": "param"
}

If any non-optional parameters are missing or undocumented parameters occur, parseOptions will throw an error.

FAQs

Package last updated on 03 Feb 2017

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

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.