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

argvments

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

argvments

Parse command line arguments

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

argvments Build Status

Parse command line arguments

If you're looking to use this in a CLI app, you probably want meow instead.

Install

$ npm install argvments

Usage

$ ./unicorn.js foobar --rainbow
const argvments = require('argvments');

argvments(process.argv.slice(2));
/*
	{
		input: ['foobar'],
		flags: {
			rainbow: true
		}
	}
*/

API

argvments(input, [options])

input

Type: Array

Arguments to parse.

options

Type: Object

Same as minimist. Keys passed to the default option are decamelized, so you can for example pass in fooBar: 'baz' and have it be the default for the --foo-bar flag.

any

Type: Array

In addition to the types supplied by minimist (boolean and string) you can also choose to treat your arguments as any. This will treat --rainbow as true and --rainbow=foo as foo.

const argvments = require('argvments');

const argv = argvments(process.argv.slice(2), {any: ['rainbow']});
console.log(argv.flags.rainbow);
$ ./unicorn.js --rainbow
//=> true

$ ./unicorn.js --rainbow=foo
//=> 'foo'

$ ./unicorn.js --rainbow foo
//=> true
inferType

Type: boolean
Default: false

Infer the argument type.

By default, the argument 5 in $ foo 5 becomes a string. Enabling this would infer it as a number.

  • meow - CLI app helper

License

MIT © Kevin Mårtensson

Keywords

FAQs

Package last updated on 23 Sep 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

  • 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