Quickly scan for CLI flags and arguments
This is a very basic, fast, and lightweight alternative to minimist. It only exists because I find that I usually don't need most of what minimist has to offer.
For now, there's no configuration options. Instead, mri just parses raw CLI flags (single or group) and assigns a value to those keys.
Note: Defaults, aliases, and type-casting are not supported. However, this may change in the future. 🤔
$ npm install --save mri
$ demo-cli --foo --bar=baz -mtv -- hello worldconst mri = require('mri');
const args = process.argv.slice(2);
mri(args);
//=> { _: ['hello', 'world'], foo:true, bar:'baz', m:true, t:true, v:true }Type: array
Default: []
An array of arguments to parse. For CLI usage, send process.argv.slice(2). See process.argv for info.
mri
--> 348,312 ops/sec ±0.20% (94 runs sampled)
yargs
--> 16,388 ops/sec ±0.56% (89 runs sampled)
minimist
--> 144,801 ops/sec ±0.81% (89 runs sampled)
MIT © Luke Edwards