{"_id":"mri","_rev":"825171","name":"mri","description":"Quickly scan for CLI flags and arguments","dist-tags":{"latest":"1.2.0"},"maintainers":[{"name":"lukeed","email":"luke@lukeed.com"}],"time":{"modified":"2021-09-12T22:40:54.000Z","created":"2017-04-16T20:48:22.204Z","1.2.0":"2021-09-12T22:35:52.359Z","1.1.6":"2020-07-14T22:31:02.214Z","1.1.5":"2020-03-24T04:49:02.099Z","1.1.4":"2018-12-23T19:08:08.009Z","1.1.3":"2018-12-21T11:14:31.667Z","1.1.2":"2018-12-21T10:07:44.407Z","1.1.1":"2018-05-07T08:21:52.924Z","1.1.0":"2017-06-14T19:34:10.176Z","1.0.0":"2017-06-12T22:26:58.026Z","0.1.0":"2017-04-16T20:48:22.204Z"},"users":{"btd":true,"lgatica":true,"vio":true,"shanewholloway":true,"bsdprojects":true,"reyronald":true},"author":{"name":"Luke Edwards","email":"luke.edwards05@gmail.com","url":"https://lukeed.com"},"repository":{"type":"git","url":"git+https://github.com/lukeed/mri.git"},"versions":{"1.2.0":{"name":"mri","version":"1.2.0","description":"Quickly scan for CLI flags and arguments","repository":{"type":"git","url":"git+https://github.com/lukeed/mri.git"},"module":"lib/index.mjs","main":"lib/index.js","types":"index.d.ts","license":"MIT","author":{"name":"Luke Edwards","email":"luke.edwards05@gmail.com","url":"https://lukeed.com"},"engines":{"node":">=4"},"scripts":{"build":"bundt","bench":"node bench","pretest":"npm run build","test":"tape test/*.js | tap-spec"},"keywords":["argv","arguments","cli","minimist","options","optimist","parser","args"],"devDependencies":{"bundt":"1.0.2","tap-spec":"4.1.2","tape":"4.13.3"},"gitHead":"e73e9f9d5b02124d14ac17dac2c4801687d3e99a","bugs":{"url":"https://github.com/lukeed/mri/issues"},"homepage":"https://github.com/lukeed/mri#readme","_id":"mri@1.2.0","_npmVersion":"6.4.1","_nodeVersion":"10.13.0","_npmUser":{"name":"lukeed","email":"luke@lukeed.com"},"dist":{"shasum":"6721480fec2a11a4889861115a48b6cbe7cc8f0b","size":4448,"noattachment":false,"key":"/mri/-/mri-1.2.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/mri/download/mri-1.2.0.tgz"},"directories":{},"maintainers":[{"name":"lukeed","email":"luke@lukeed.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/mri_1.2.0_1631486152223_0.9086584690112476"},"_hasShrinkwrap":false,"publish_time":1631486152359,"_cnpm_publish_time":1631486152359},"1.1.6":{"name":"mri","version":"1.1.6","description":"Quickly scan for CLI flags and arguments","repository":{"type":"git","url":"git+https://github.com/lukeed/mri.git"},"module":"lib/index.mjs","main":"lib/index.js","license":"MIT","author":{"name":"Luke Edwards","email":"luke.edwards05@gmail.com","url":"https://lukeed.com"},"engines":{"node":">=4"},"scripts":{"build":"bundt","bench":"node bench","pretest":"npm run build","test":"tape test/*.js | tap-spec"},"keywords":["argv","arguments","cli","minimist","options","optimist","parser","args"],"devDependencies":{"bundt":"1.0.2","tap-spec":"4.1.2","tape":"4.13.3"},"gitHead":"52f722e07216412424abf1ec1c01477b0760a29f","bugs":{"url":"https://github.com/lukeed/mri/issues"},"homepage":"https://github.com/lukeed/mri#readme","_id":"mri@1.1.6","_nodeVersion":"12.18.2","_npmVersion":"6.14.5","dist":{"shasum":"49952e1044db21dbf90f6cd92bc9c9a777d415a6","size":4171,"noattachment":false,"key":"/mri/-/mri-1.1.6.tgz","tarball":"http://registry.cnpm.dingdandao.com/mri/download/mri-1.1.6.tgz"},"maintainers":[{"name":"lukeed","email":"luke@lukeed.com"}],"_npmUser":{"name":"lukeed","email":"luke@lukeed.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/mri_1.1.6_1594765862079_0.27244387719891305"},"_hasShrinkwrap":false,"publish_time":1594765862214,"_cnpm_publish_time":1594765862214},"1.1.5":{"name":"mri","version":"1.1.5","description":"Quickly scan for CLI flags and arguments","repository":{"type":"git","url":"git+https://github.com/lukeed/mri.git"},"main":"lib/index.js","license":"MIT","author":{"name":"Luke Edwards","email":"luke.edwards05@gmail.com","url":"lukeed.com"},"engines":{"node":">=4"},"scripts":{"bench":"node bench","test":"tape test/*.js | tap-spec"},"keywords":["argv","arguments","cli","minimist","options","optimist","parser","args"],"devDependencies":{"tap-spec":"^4.1.1","tape":"^4.6.3"},"gitHead":"8e0a0f4bb88696a44b62d3d17311828b96a9640a","bugs":{"url":"https://github.com/lukeed/mri/issues"},"homepage":"https://github.com/lukeed/mri#readme","_id":"mri@1.1.5","_npmVersion":"6.4.1","_nodeVersion":"10.13.0","_npmUser":{"name":"lukeed","email":"luke@lukeed.com"},"dist":{"shasum":"ce21dba2c69f74a9b7cf8a1ec62307e089e223e0","size":4042,"noattachment":false,"key":"/mri/-/mri-1.1.5.tgz","tarball":"http://registry.cnpm.dingdandao.com/mri/download/mri-1.1.5.tgz"},"maintainers":[{"name":"lukeed","email":"luke@lukeed.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/mri_1.1.5_1585025341969_0.652978111866064"},"_hasShrinkwrap":false,"publish_time":1585025342099,"_cnpm_publish_time":1585025342099},"1.1.4":{"name":"mri","version":"1.1.4","description":"Quickly scan for CLI flags and arguments","repository":{"type":"git","url":"git+https://github.com/lukeed/mri.git"},"main":"lib/index.js","license":"MIT","author":{"name":"Luke Edwards","email":"luke.edwards05@gmail.com","url":"lukeed.com"},"engines":{"node":">=4"},"scripts":{"bench":"node bench","test":"tape test/*.js | tap-spec"},"keywords":["argv","arguments","cli","minimist","options","optimist","parser","args"],"devDependencies":{"tap-spec":"^4.1.1","tape":"^4.6.3"},"gitHead":"40051e689d80f77136ac990dafa2f27cdca48086","bugs":{"url":"https://github.com/lukeed/mri/issues"},"homepage":"https://github.com/lukeed/mri#readme","_id":"mri@1.1.4","_npmVersion":"6.4.1","_nodeVersion":"10.12.0","_npmUser":{"name":"lukeed","email":"luke@lukeed.com"},"dist":{"shasum":"7cb1dd1b9b40905f1fac053abe25b6720f44744a","size":4006,"noattachment":false,"key":"/mri/-/mri-1.1.4.tgz","tarball":"http://registry.cnpm.dingdandao.com/mri/download/mri-1.1.4.tgz"},"maintainers":[{"name":"lukeed","email":"luke@lukeed.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/mri_1.1.4_1545592087832_0.8010756437872082"},"_hasShrinkwrap":false,"publish_time":1545592088009,"_cnpm_publish_time":1545592088009},"1.1.3":{"name":"mri","version":"1.1.3","description":"Quickly scan for CLI flags and arguments","repository":{"type":"git","url":"git+https://github.com/lukeed/mri.git"},"main":"lib/index.js","license":"MIT","author":{"name":"Luke Edwards","email":"luke.edwards05@gmail.com","url":"lukeed.com"},"engines":{"node":">=4"},"scripts":{"bench":"node bench","test":"tape test/*.js | tap-spec"},"keywords":["argv","arguments","cli","minimist","options","optimist","parser","args"],"devDependencies":{"tap-spec":"^4.1.1","tape":"^4.6.3"},"gitHead":"c621d869aa12b8824274eea692e95327ed144ff6","bugs":{"url":"https://github.com/lukeed/mri/issues"},"homepage":"https://github.com/lukeed/mri#readme","_id":"mri@1.1.3","_npmVersion":"6.4.1","_nodeVersion":"10.13.0","_npmUser":{"name":"lukeed","email":"luke@lukeed.com"},"dist":{"shasum":"d100e7d22f99c82c920481d2b8e535f83ffb6ad9","size":4007,"noattachment":false,"key":"/mri/-/mri-1.1.3.tgz","tarball":"http://registry.cnpm.dingdandao.com/mri/download/mri-1.1.3.tgz"},"maintainers":[{"name":"lukeed","email":"luke@lukeed.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/mri_1.1.3_1545390871509_0.9327435621858995"},"_hasShrinkwrap":false,"publish_time":1545390871667,"_cnpm_publish_time":1545390871667},"1.1.2":{"name":"mri","version":"1.1.2","description":"Quickly scan for CLI flags and arguments","repository":{"type":"git","url":"git+https://github.com/lukeed/mri.git"},"main":"lib/index.js","license":"MIT","author":{"name":"Luke Edwards","email":"luke.edwards05@gmail.com","url":"lukeed.com"},"engines":{"node":">=4"},"scripts":{"bench":"node bench","test":"tape test/*.js | tap-spec"},"keywords":["argv","arguments","cli","minimist","options","optimist","parser","args"],"devDependencies":{"tap-spec":"^4.1.1","tape":"^4.6.3"},"gitHead":"ad57e8b9f7d8599633c6db1e7562b974e4d88143","bugs":{"url":"https://github.com/lukeed/mri/issues"},"homepage":"https://github.com/lukeed/mri#readme","_id":"mri@1.1.2","_npmVersion":"6.4.1","_nodeVersion":"10.13.0","_npmUser":{"name":"lukeed","email":"luke@lukeed.com"},"dist":{"shasum":"b151cb024cba1c9d11d9915569ba3286052caf19","size":4005,"noattachment":false,"key":"/mri/-/mri-1.1.2.tgz","tarball":"http://registry.cnpm.dingdandao.com/mri/download/mri-1.1.2.tgz"},"maintainers":[{"name":"lukeed","email":"luke@lukeed.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/mri_1.1.2_1545386864197_0.4590615758560028"},"_hasShrinkwrap":false,"publish_time":1545386864407,"_cnpm_publish_time":1545386864407},"1.1.1":{"name":"mri","version":"1.1.1","description":"Quickly scan for CLI flags and arguments","license":"MIT","repository":{"type":"git","url":"git+https://github.com/lukeed/mri.git"},"main":"lib/index.js","files":["lib"],"author":{"name":"Luke Edwards","email":"luke.edwards05@gmail.com","url":"lukeed.com"},"engines":{"node":">=4"},"scripts":{"bench":"node bench","test":"tape test/*.js | tap-spec"},"keywords":["argv","arguments","cli","minimist","options","optimist","parser","args"],"devDependencies":{"tap-spec":"^4.1.1","tape":"^4.6.3"},"gitHead":"b19beb2d66aef800ecbd8eff5a4f44ad84884503","bugs":{"url":"https://github.com/lukeed/mri/issues"},"homepage":"https://github.com/lukeed/mri#readme","_id":"mri@1.1.1","_shasum":"85aa26d3daeeeedf80dc5984af95cc5ca5cad9f1","_from":".","_npmVersion":"3.10.10","_nodeVersion":"6.12.0","_npmUser":{"name":"lukeed","email":"luke@lukeed.com"},"dist":{"shasum":"85aa26d3daeeeedf80dc5984af95cc5ca5cad9f1","size":4234,"noattachment":false,"key":"/mri/-/mri-1.1.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/mri/download/mri-1.1.1.tgz"},"maintainers":[{"name":"lukeed","email":"luke@lukeed.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/mri_1.1.1_1525681312835_0.21257163708592253"},"_hasShrinkwrap":false,"publish_time":1525681312924,"_cnpm_publish_time":1525681312924},"1.1.0":{"name":"mri","version":"1.1.0","description":"Quickly scan for CLI flags and arguments","license":"MIT","repository":{"type":"git","url":"git+https://github.com/lukeed/mri.git"},"main":"lib/index.js","files":["lib"],"author":{"name":"Luke Edwards","email":"luke.edwards05@gmail.com","url":"lukeed.com"},"engines":{"node":">=4"},"scripts":{"bench":"node bench","precommit":"prettier --single-quote --use-tabs --print-width=100 --write '{lib,test}/*.js'","test":"tape test/*.js | tap-spec"},"keywords":["argv","arguments","cli","minimist","options","optimist","parser"],"devDependencies":{"husky":"^0.13.4","prettier":"^1.1.0","tap-spec":"^4.1.1","tape":"^4.6.3"},"gitHead":"e776e7747030dd71535bd05caa832d7615cabcd4","bugs":{"url":"https://github.com/lukeed/mri/issues"},"homepage":"https://github.com/lukeed/mri#readme","_id":"mri@1.1.0","_shasum":"5c0a3f29c8ccffbbb1ec941dcec09d71fa32f36a","_from":".","_npmVersion":"3.10.8","_nodeVersion":"6.9.1","_npmUser":{"name":"lukeed","email":"luke@lukeed.com"},"dist":{"shasum":"5c0a3f29c8ccffbbb1ec941dcec09d71fa32f36a","size":4290,"noattachment":false,"key":"/mri/-/mri-1.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/mri/download/mri-1.1.0.tgz"},"maintainers":[{"name":"lukeed","email":"luke@lukeed.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/mri-1.1.0.tgz_1497468850000_0.28084479877725244"},"directories":{},"publish_time":1497468850176,"_cnpm_publish_time":1497468850176,"_hasShrinkwrap":false},"1.0.0":{"name":"mri","version":"1.0.0","description":"Quickly scan for CLI flags and arguments","license":"MIT","repository":{"type":"git","url":"git+https://github.com/lukeed/mri.git"},"main":"lib/index.js","files":["lib"],"author":{"name":"Luke Edwards","email":"luke.edwards05@gmail.com","url":"lukeed.com"},"engines":{"node":">=4"},"scripts":{"bench":"node bench","precommit":"prettier --single-quote --use-tabs --print-width=100 --write '{lib,test}/*.js'","test":"tape test/*.js | tap-spec"},"keywords":["argv","arguments","cli","minimist","options","optimist","parser"],"devDependencies":{"husky":"^0.13.4","prettier":"^1.1.0","tap-spec":"^4.1.1","tape":"^4.6.3"},"gitHead":"815cc91c9a25cc29e8e05e1a14f0271861c2786b","bugs":{"url":"https://github.com/lukeed/mri/issues"},"homepage":"https://github.com/lukeed/mri#readme","_id":"mri@1.0.0","_shasum":"08e9fb1e08072c1ff85ffe3a7e97f3557515a7ab","_from":".","_npmVersion":"3.10.8","_nodeVersion":"6.9.1","_npmUser":{"name":"lukeed","email":"luke@lukeed.com"},"dist":{"shasum":"08e9fb1e08072c1ff85ffe3a7e97f3557515a7ab","size":4003,"noattachment":false,"key":"/mri/-/mri-1.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/mri/download/mri-1.0.0.tgz"},"maintainers":[{"name":"lukeed","email":"luke@lukeed.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/mri-1.0.0.tgz_1497306417440_0.12435552710667253"},"directories":{},"publish_time":1497306418026,"_hasShrinkwrap":false,"_cnpm_publish_time":1497306418026},"0.1.0":{"name":"mri","version":"0.1.0","description":"Quickly scan for CLI flags and arguments","license":"MIT","repository":{"type":"git","url":"git+https://github.com/lukeed/mri.git"},"main":"lib/index.js","files":["lib"],"author":{"name":"Luke Edwards","email":"luke.edwards05@gmail.com","url":"lukeed.com"},"engines":{"node":">=4"},"scripts":{"test":"prettier --single-quote --use-tabs --print-width=100 --write 'lib/*.js'"},"keywords":["argv","arguments","cli","minimist","options","optimist","parser"],"devDependencies":{"prettier":"^1.1.0"},"gitHead":"b4a0d716383356e2b3ab36128d9fa738b6816e94","bugs":{"url":"https://github.com/lukeed/mri/issues"},"homepage":"https://github.com/lukeed/mri#readme","_id":"mri@0.1.0","_shasum":"5b9bacd3a1620e4f1207d3707a4b6bc2636b1dfb","_from":".","_npmVersion":"3.10.8","_nodeVersion":"6.9.1","_npmUser":{"name":"lukeed","email":"luke@lukeed.com"},"dist":{"shasum":"5b9bacd3a1620e4f1207d3707a4b6bc2636b1dfb","size":3493,"noattachment":false,"key":"/mri/-/mri-0.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/mri/download/mri-0.1.0.tgz"},"maintainers":[{"name":"lukeed","email":"luke@lukeed.com"}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/mri-0.1.0.tgz_1492375701896_0.057724215323105454"},"directories":{},"publish_time":1492375702204,"_cnpm_publish_time":1492375702204,"_hasShrinkwrap":false}},"readme":"# mri [![CI](https://github.com/lukeed/mri/workflows/CI/badge.svg?branch=master&event=push)](https://github.com/lukeed/mri/actions)\n\n> Quickly scan for CLI flags and arguments\n\nThis is a [fast](#benchmarks) and lightweight alternative to [`minimist`](https://github.com/substack/minimist) and [`yargs-parser`](https://github.com/yargs/yargs-parser).\n\nIt only exists because I find that I usually don't need most of what `minimist` and `yargs-parser` have to offer. However, `mri` is similar _enough_ that it might function as a \"drop-in replacement\" for you, too!\n\nSee [Comparisons](#comparisons) for more info.\n\n## Install\n\n```sh\n$ npm install --save mri\n```\n\n## Usage\n\n```sh\n$ demo-cli --foo --bar=baz -mtv -- hello world\n```\n\n```js\nconst mri = require('mri');\n\nconst argv = process.argv.slice(2);\n\nmri(argv);\n//=> { _: ['hello', 'world'], foo:true, bar:'baz', m:true, t:true, v:true }\n\nmri(argv, { boolean:['bar'] });\n//=> { _: ['baz', 'hello', 'world'], foo:true, bar:true, m:true, t:true, v:true }\n\nmri(argv, {\n  alias: {\n    b: 'bar',\n    foo: ['f', 'fuz']\n  }\n});\n//=> { _: ['hello', 'world'], foo:true, f:true, fuz:true, b:'baz', bar:'baz', m:true, t:true, v:true }\n```\n\n## API\n\n### mri(args, options)\nReturn: `Object`\n\n#### args\nType: `Array`<br>\nDefault: `[]`\n\nAn array of arguments to parse. For CLI usage, send `process.argv.slice(2)`. See [`process.argv`](https://nodejs.org/docs/latest/api/process.html#process_process_argv) for info.\n\n#### options.alias\nType: `Object`<br>\nDefault: `{}`\n\nAn object of keys whose values are `String`s or `Array<String>` of aliases. These will be added to the parsed output with matching values.\n\n#### options.boolean\nType: `Array|String`<br>\nDefault: `[]`\n\nA single key (or array of keys) that should be parsed as `Boolean`s.\n\n#### options.default\nType: `Object`<br>\nDefault: `{}`\n\nAn `key:value` object of defaults. If a default is provided for a key, its type (`typeof`) will be used to cast parsed arguments.\n\n```js\nmri(['--foo', 'bar']);\n//=> { _:[], foo:'bar' }\n\nmri(['--foo', 'bar'], {\n  default: { foo:true, baz:'hello', bat:42 }\n});\n//=> { _:['bar'], foo:true, baz:'hello', bat:42 }\n```\n\n> **Note:** Because `--foo` has a default of `true`, its output is cast to a Boolean. This means that `foo=true`, making `'bar'` an extra argument (`_` key).\n\n#### options.string\nType: `Array|String`<br>\nDefault: `[]`\n\nA single key (or array of keys) that should be parsed as `String`s.\n\n#### options.unknown\nType: `Function`<br>\nDefault: `undefined`\n\nCallback that is run when a parsed flag has not been defined as a known key or alias. Its only parameter is the unknown flag itself; eg `--foobar` or `-f`.\n\nOnce an unknown flag is encountered, parsing will terminate, regardless of your return value.\n\n> **Note:** `mri` _only_ checks for unknown flags if `options.unknown` **and** `options.alias` are populated. Otherwise, everything will be accepted.\n\n\n## Comparisons\n\n#### minimist\n\n- `mri` is 5x faster (see [benchmarks](#benchmarks))\n- Numerical values are cast as `Number`s when possible\n  - A key (and its aliases) will always honor `opts.boolean` or `opts.string`\n- Short flag groups are treated as `Boolean`s by default:\n    ```js\n    minimist(['-abc', 'hello']);\n    //=> { _:[], a:'', b:'', c:'hello' }\n\n    mri(['-abc', 'hello']);\n    //=> { _:[], a:true, b:true, c:'hello' }\n    ```\n- The `opts.unknown` behaves differently:\n  - Unlike `minimist`, `mri` will not continue continue parsing after encountering an unknown flag\n- Missing `options`:\n  - `opts.stopEarly`\n  - `opts['--']`\n- Ignores newlines (`\\n`) within args (see [test](https://github.com/substack/minimist/blob/master/test/parse.js#L69-L80))\n- Ignores slashBreaks within args (see [test](https://github.com/substack/minimist/blob/master/test/parse.js#L147-L157))\n- Ignores dot-nested flags (see [test](https://github.com/substack/minimist/blob/master/test/parse.js#L180-L197))\n\n#### yargs-parser\n\n- `mri` is 40x faster (see [benchmarks](#benchmarks))\n- Numerical values are cast as `Number`s when possible\n  - A key (and its aliases) will always honor `opts.boolean` or `opts.string`\n- Missing `options`:\n  - `opts.array`\n  - `opts.config`\n  - `opts.coerce`\n  - `opts.count`\n  - `opts.envPrefix`\n  - `opts.narg`\n  - `opts.normalize`\n  - `opts.configuration`\n  - `opts.number`\n  - `opts['--']`\n- Missing [`parser.detailed()`](https://github.com/yargs/yargs-parser#requireyargs-parserdetailedargs-opts) method\n- No [additional configuration](https://github.com/yargs/yargs-parser#configuration) object\n- Added [`options.unknown`](#optionsunknown) feature\n\n\n## Benchmarks\n\n> Running Node.js v10.13.0\n\n```\nLoad Times:\n  nopt          3.179ms\n  yargs-parser  2.137ms\n  minimist      0.746ms\n  mri           0.517ms\n\nBenchmark:\n  minimist      x    328,747 ops/sec ±1.09% (89 runs sampled)\n  mri           x  1,622,801 ops/sec ±0.94% (92 runs sampled)\n  nopt          x    888,223 ops/sec ±0.22% (92 runs sampled)\n  yargs-parser  x     30,538 ops/sec ±0.81% (91 runs sampled)\n```\n\n## License\n\nMIT © [Luke Edwards](https://lukeed.com)\n","_attachments":{},"homepage":"https://github.com/lukeed/mri#readme","bugs":{"url":"https://github.com/lukeed/mri/issues"},"license":"MIT"}