description: parse argument options

license: MIT

readme:
# minimist <sup>[![Version Badge][npm-version-svg]][package-url]</sup>

[![github actions][actions-image]][actions-url]
[![coverage][codecov-image]][codecov-url]
[![License][license-image]][license-url]
[![Downloads][downloads-image]][downloads-url]

[![npm badge][npm-badge-png]][package-url]

parse argument options

This module is the guts of optimist's argument parser without all the
fanciful decoration.

# example

``` js
var argv = require('minimist')(process.argv.slice(2));
console.log(argv);
```

```
$ node example/parse.js -a beep -b boop
{ _: [], a: 'beep', b: 'boop' }
```

```
$ node example/parse.js -x 3 -y 4 -n5 -abc --beep=boop foo bar baz
{
	_: ['foo', 'bar', 'baz'],
	x: 3,
	y: 4,
	n: 5,
	a: true,
	b: true,
	c: true,
	beep: 'boop'
}
```

# security

Previous versions had a prototype pollution bug that could cause privilege
escalation in some circumstances when handling untrusted user input.

Please use version 1.2.6 or later:

* https://security.snyk.io/vuln/SNYK-JS-MINIMIST-2429795 (version <=1.2.5)
* https://snyk.io/vuln/SNYK-JS-MINIMIST-559764 (version <=1.2.3)

# methods

``` js
var parseArgs = require('minimist')
```

## var argv = parseArgs(args, opts={})

Return an argument object `argv` populated with the array arguments from `args`.

`argv._` contains all the arguments that didn't have an option associated with
them.

Numeric-looking arguments will be returned as numbers unless `opts.string` or
`opts.boolean` is set for that argument name.

Any arguments after `'--'` will not be parsed and will end up in `argv._`.

options can be:

* `opts.string` - a string or array of strings argument names to always treat as
strings
* `opts.boolean` - a boolean, string or array of strings to always treat as
booleans. if `true` will treat all double hyphenated arguments without equal signs
as boolean (e.g. affects `--foo`, not `-f` or `--foo=bar`)
* `opts.alias` - an object mapping string names to strings or arrays of string
argument names to use as aliases
* `opts.default` - an object mapping string argument names to default values
* `opts.stopEarly` - when true, populate `argv._` with everything after the
first non-option
* `opts['--']` - when true, populate `argv._` with everything before the `--`
and `argv['--']` with everything after the `--`. Here's an example:

  ```
  > require('./')('one two three -- four five --six'.split(' '), { '--': true })
  {
    _: ['one', 'two', 'three'],
    '--': ['four', 'five', '--six']
  }
  ```

  Note that with `opts['--']` set, parsing for arguments still stops after the
  `--`.

* `opts.unknown` - a function which is invoked with a command line parameter not
defined in the `opts` configuration object. If the function returns `false`, the
unknown option is not added to `argv`.

# install

With [npm](https://npmjs.org) do:

```
npm install minimist
```

# license

MIT

[package-url]: https://npmjs.org/package/minimist
[npm-version-svg]: https://versionbadg.es/minimistjs/minimist.svg
[npm-badge-png]: https://nodei.co/npm/minimist.png?downloads=true&stars=true
[license-image]: https://img.shields.io/npm/l/minimist.svg
[license-url]: LICENSE
[downloads-image]: https://img.shields.io/npm/dm/minimist.svg
[downloads-url]: https://npm-stat.com/charts.html?package=minimist
[codecov-image]: https://codecov.io/gh/minimistjs/minimist/branch/main/graphs/badge.svg
[codecov-url]: https://app.codecov.io/gh/minimistjs/minimist/
[actions-image]: https://img.shields.io/endpoint?url=https://github-actions-badge-u3jn4tfpocch.runkit.sh/minimistjs/minimist
[actions-url]: https://github.com/minimistjs/minimist/actions

minimist

description: parse argument options

test: tap test/*.js

coverage: covert test/*.js

type: git

keywords: argv getopt parser optimist

description: parse argument options

description: parse argument options

description: parse argument options

description: parse argument options

description: parse argument options

description: parse argument options

description: parse argument options

description: parse argument options

description: parse argument options

description: parse argument options

description: parse argument options

description: parse argument options

description: parse argument options

description: parse argument options

description: parse argument options

description: parse argument options

description: parse argument options

description: parse argument options

description: parse argument options

description: parse argument options

description: parse argument options

description: parse argument options

description: parse argument options

description: parse argument options

description: parse argument options

npm-signature:
-----BEGIN PGP SIGNATURE-----
Version: OpenPGP.js v4.10.10
Comment: https://openpgpjs.org

wsFzBAEBCAAGBQJiOTl2ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b
EgJ2VmrHWQ/+M1DlrfJO6t4u34gsO6W25Ya5eyBICPBYhHGX7XHY6WAfMK54
mXp06/beXLmXEExDbyYsJVeC5TX5pLQyOpi0sAJq377SR8DR2V2biVOLDiFD
5lcbE04h3ccz0/J5m3dLuEzbVwi0sTJeDTAVYkBheCWhotA2RKK/4x/3Cm2v
8fLvX9i9l/mAlJl2V2E9u+0oQnUBqWOtP0zbUBNe2rR/cGld6OkxxETBbsti
mSEJXI36XBQ1rRQaJ5AKlnCs2ooCf8nSDWWcV4QiH0GukQRC1d7QwzCUPAFI
EjMGqbIxYQbks1t9KLLheGKLXJM763NWPNU8456WJjmAbogMK75mlyC8CMSn
W2EPNhEhWbfhJ7G2Kz1J0i5HPUD1REX5mean3hm6w1CJFi30lmAya9JAMvvv
0ce+Xzk3CUzXn/knh+faKGIrAZELT8CnnGo0bvvSNv/UL9Z+MrtigEX1AJRS
BavdDxjttMcGgdYcsCpchbcgp5sVXxT20tzakGJphkdDypQJ0QiueZKUVkIs
jOCfeHBIUV8Pft0LiJv5r2Xa4KbGgRcd8eUdGAAXBT++6o5cUtnnjbAlqPNP
uf8DyBD/NJFd/C2Wk7m5PJkG5IjP7zErmJLbBaifeYcXTQsH2NNf+AzJh6Lx
12omUQn4FF6Wk8D6cdBbhK2iPyobfxWy80o=
=hKft
-----END PGP SIGNATURE-----

description: parse argument options

prepublish: not-in-publish || npm run prepublishOnly

postversion: auto-changelog && git add CHANGELOG.md && git commit --no-edit --amend && git tag -f "v$(node -e "console.log(require('./package.json').version)")"

output: CHANGELOG.md

npm-signature:
-----BEGIN PGP SIGNATURE-----
Version: OpenPGP.js v4.10.10
Comment: https://openpgpjs.org

wsFzBAEBCAAGBQJjRMUwACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b
EgJ2VmqVmw//crUOeiwaoCV6oQdvP0iwXRXu2tig8B18RThVx8tq7RMFDXxQ
18JbLz/puqiaAqpVj5NoNNqwSphBsKT1blred5B7BTvjA6PZ0oNoAt0mX75K
Zc61T9F1ORDUksHn/Oz5ZJAj6mKSxWtbwX/FvGRarOJaU0CVGNs+0rwtzaD0
r+0Nh66lNh9HJ8btepvp5WQW0qRAN96bN91wXPkxg3y38Y1hsC0tepm8EghD
Jq8AIe3oLMu1+TsHhGXTYxrNihfyRFYi1TGibewYpqlDoT8gcYmJtVQ3ophr
g5srTKt9rA3lNENAPModCpGp1sHr/JaEKuHlcJlnJjJuSUK6ASCptY/4oO+Q
eyZNfeCI0+gaHWjTqqFr8VMlFO99MhHfC1+swqcZwi0b0izJWm0M91NgonJP
PUbovszUbYKLth7RP6/UMGuf/a/GGXqpchVuVfIsP72DcUpihb2ItkSEj9oY
+dhY59Zj7+e4hUG5aow05UBOJ717lIq44kv3xTymFQPZRTHek+R41gIdX0d0
gaZVKVoIb9Qq3QFcMOpll8E5tDfqnU0Zhuo5l0aO4F7KguSNNfybPnmjjrYy
qryciJMJcczqim+4xL0SG6PCelcj71sHZCSkyMCZWenhX2rtBavGVhue0CGC
uH2wqiD4Vr5UlHGSTpLbv4KAPzQxZ7M5Nbw=
=uJA+
-----END PGP SIGNATURE-----

description: parse argument options

output: CHANGELOG.md

npm-signature:
-----BEGIN PGP SIGNATURE-----
Version: OpenPGP.js v4.10.10
Comment: https://openpgpjs.org

wsFzBAEBCAAGBQJjRdT5ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b
EgJ2Vmp+aA//ZhFxXbpWOBjhpzNGgUUgqQplsZVz4WVKuTOhtnE1zVuxTx9g
VRVfNOk79kn5ne+mIt2w/CzClEw8FQqkS2TwL2bTGhnEtFUTj3fD5bpnWl8t
5m6iyo3zfiGf92GfrHbIRqZuVxax9p35AHjbsmG+0hxFegXAL9cy4zEdd9qL
qn30TNEq+AJMuOQ/13HLN5sku9yzXYmVTXClxFZV/4r+PjvmJOxvfzzYc4+n
A+2DosaK/vu9d1496q7Yatk1mtWjdU4DcGDHXujf2pKe6ABVk18Vt/cLokXL
FOiU245lYgbxZyZvb1N1Ct1rSpjpglSInpJBbQ7ycQ41mlC00Y29FVmLTEbQ
cFgZrodJqXswC25+1RTqe55KW/UG6bMGeRxe9kwMheGvgLJdBQ6YIKYqnn2j
ojNr1x8ftLceEBjKVCS9cMkBktgUuJK4vLGJMG1BNTFg/hlnMUlKJBFRgXEW
p/aMvn7VWRo/jss3IwL61NifPE2+GCBc3K9RovymfWbZRn04wtVqSJjMS8Sb
McoXN0j5Vd+TyXDQ0g9IQd54UmcBYG2vIKx6Dhfw+Rzl66FfcSTUCvgJUU/j
pPYtuJUnkc9y1fuR8s+8Vode9KmZYcQXMsUPq0DHB5dDM8g2VZiN8ZuEUJx9
KJuaDqu04Ubk5RomkImbBeLHrP8n+jRvETk=
=H36/
-----END PGP SIGNATURE-----

description: parse argument options

output: CHANGELOG.md

npm-signature:
-----BEGIN PGP SIGNATURE-----
Version: OpenPGP.js v4.10.10
Comment: https://openpgpjs.org

wsFzBAEBCAAGBQJj5VNlACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b
EgJ2VmrIxg/+JAgposqq0wjRXyKOjjo5BiQaurIXCVltH4hTJ7OKko0HjjUo
RxRlnI1fPtUvQaDCY0hA7kvcTs96uJ38UL925o2cUkSWvbY2BaWYS7eoqIBX
LqfLErdA/ga5ept+NU6zs8o6tSXaw+MRROlhDgi4ikcu1SyA2H1F4Ct71sbj
wLhxj6L0z5KC1wb2HS0CiWvwx3PtoMULuUmP80YZ1Fxpc43rxADLHGM1zIhh
jtzLIQkWMjKQ4KhLhi96YPWB3aIfPWwz6MYRYmRL+1VPrP/Wwww6dAkL2cR1
llVE2Y1kmYGbfFCWPSC0FYVQJwP2Duwum/Qkv6Y+4k+ggadmWIuecs27ROxl
NrYimiPRcI5j8b06j8bazCPDa0hTdHqIU3JKNQxV4ee4dvWFqH2aeeMqKxwn
ge4SYdQyx8Z2iEXKS3lOcVuac/2yH3bDNLUCMM5XwNSEg0W+Y9YtikSAoj5L
QZE+vRqZGFQLkOj9l8wBY+iVQx0cZccGNudR5Cuet0SmqILeb5zrCryIhUsw
6ri8ACJPy6cTJtnysZtBu0Q9Uhs6VIliCPlE2ZTWevWWaRfxcAFWCj6G63rP
N8YNPfd4nwQ3lb4dx/e3KAFUqCY2eYbuGZNjdtms/4NUDqN/g9R09HuxjsyG
Sz3zEGNA9YSu2r9kDbNaPla8EkFidlMtD6E=
=ccqV
-----END PGP SIGNATURE-----

description: parse argument options

output: CHANGELOG.md

npm-signature:
-----BEGIN PGP SIGNATURE-----
Version: OpenPGP.js v4.10.10
Comment: https://openpgpjs.org

wsFzBAEBCAAGBQJj5V7FACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b
EgJ2VmrRgQ//UOnz6KMAn81WnyW7HHaDJod7K1B/7esKtuUjltRxB2l8ddE/
Y0hTaRokSzDACo9p+x1OK/1d6OuCsoOlIn2ypAdGbftaTdDSWLJ0empTGXeq
4Eh6+ND9/JF4H6293+zV0feEJ29EiBgI2x9izYeo/1qGufQwszGL6JNNl0OV
vtJz1xJWnYyWKDSUoQhsf3C5GAqCUW4GDS8/XI8ZsaV6UTRJl/kawFGX0glC
c2NZtzvoKWduVyBa5XKAGyq4x1lGCDDHGwi8pt0Dt32Vm8eci9nDBc8yvRUv
TBAjRR8FkjGKNSAyR+3WU54CLyFMWCZcCaMtFBLrstR1YDP+S1ICDku6yy8I
t4Ir+HAswSkimWnMh/ehvzKQIDOw2po5QEIlS6ZZyavWFZaHCAGbJb+RbCbV
w6v1lQL8edEumEM5oJSJ5rYR+YfkWbfWRf+x3GAaqv1lSgMb1Ujen704KcNy
XMSPsYh7yuO+Vmr9Zyith0XLsBpd/aHmrQoTW9tdic/xS0RTC1g7sk5BrpNd
9ywPe0Va5F2nC22dBalXzI6qgdLBOdOC4A5IdpUoH0IivdBirifW8ncOAIy9
IJaF5ZmslIf2kLuq2+mhc3X6Z7cjBqug58whq2AEYeCRop1POtTZ4ihmGkI0
kaVMSKOyvBcFQzpShsO8Ajsn9O45p5TJ42A=
=h76k
-----END PGP SIGNATURE-----

description: parse argument options

output: CHANGELOG.md

npm-signature:
-----BEGIN PGP SIGNATURE-----
Version: OpenPGP.js v4.10.10
Comment: https://openpgpjs.org

wsFzBAEBCAAGBQJj+ageACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b
EgJ2VmpoZw/9Hi0sCVeQtVDQatxiwswU3fAhx1z6n02WfQVy0snRCY35d7Jp
WMNkesM5exIUtm3g+v8pSk13UKEqw1SFyBBwVi26DJhQVeNUnaEX/q4nPrHF
b0axV/FGCKhNrkiJpb0a1K1/vqFybnoq3X2QY4P7ALmgGTX8Dm/64KLpMZEP
k2UDNuTnNRnjeWdO6mO6CKzhhvYfeeT+Wl5UAfCWZQVHBlzwVXh6zTQN8g3L
Sl0e1+kE35mBzXnP6K9SVof8LY1/3Ggamr0xGI81KAMGUo7QrCIBzgzYS8uH
nFHLG/+sIaAHRV7c/EyCoJoDdsXw/2LF/Ty/81Vg0YOVYb5PBh71+TUOrPrD
dhO4x3/xOUxeJgdFErJESKhmUy+oXlyiudgyv44gGSsKF8W2PuK4KUTTJGsO
FZZMJDtMKne3o5K7z11tZreA9lPDsVThDiPtlRJypllm26iG4YgYirQ2nVs6
ky4HI4qnlhC8Qs5L06atYJMvHY0HVoUGMRKTdLDVDywdaA1D54wGg2pOpTYW
MPVffCgsi92JnNCKkn9o7HVCN3u/ZugZRqND0JL1BSI/AVlCWtK2Jjlaiw0F
IhJnMdiKTak9QafJEzbqgRYMXFVP2CP2hFbK/mV8duCCkAoJLME3744PoLhO
a2AKcIGxP4FdQJirELoSeDzVEKXjck1HzTk=
=WBqU
-----END PGP SIGNATURE-----