{"id":13492039,"url":"https://github.com/lukeed/mri","last_synced_at":"2025-10-09T18:23:27.810Z","repository":{"id":19985423,"uuid":"88438486","full_name":"lukeed/mri","owner":"lukeed","description":"Quickly scan for CLI flags and arguments","archived":false,"fork":false,"pushed_at":"2024-03-07T13:07:51.000Z","size":54,"stargazers_count":653,"open_issues_count":7,"forks_count":19,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-10-07T08:30:35.550Z","etag":null,"topics":["args","argv","cli","cli-flags","command-line","flags","minimist","parser","yargs"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lukeed.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"license.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"lukeed"}},"created_at":"2017-04-16T19:45:21.000Z","updated_at":"2025-09-14T17:13:11.000Z","dependencies_parsed_at":"2022-08-07T09:15:47.905Z","dependency_job_id":"9b8f5db8-1967-4535-b7f4-19b6bb4f0661","html_url":"https://github.com/lukeed/mri","commit_stats":{"total_commits":81,"total_committers":4,"mean_commits":20.25,"dds":0.03703703703703709,"last_synced_commit":"62b9ce4f25e1f7b476c99858c20882d86c010085"},"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"purl":"pkg:github/lukeed/mri","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lukeed%2Fmri","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lukeed%2Fmri/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lukeed%2Fmri/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lukeed%2Fmri/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lukeed","download_url":"https://codeload.github.com/lukeed/mri/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lukeed%2Fmri/sbom","scorecard":{"id":604497,"data":{"date":"2025-08-11","repo":{"name":"github.com/lukeed/mri","commit":"62b9ce4f25e1f7b476c99858c20882d86c010085"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.4,"checks":[{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Code-Review","score":0,"reason":"Found 1/30 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:11: update your workflow using https://app.stepsecurity.io/secureworkflow/lukeed/mri/ci.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:12: update your workflow using https://app.stepsecurity.io/secureworkflow/lukeed/mri/ci.yml/master?enable=pin","Warn: npmCommand not pinned by hash: .github/workflows/ci.yml:18","Info:   0 out of   2 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   1 npmCommand dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/ci.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: license.md:0","Info: FSF or OSI recognized license: MIT License: license.md:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 1 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-21T01:15:54.340Z","repository_id":19985423,"created_at":"2025-08-21T01:15:54.341Z","updated_at":"2025-08-21T01:15:54.341Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279001309,"owners_count":26083040,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-09T02:00:07.460Z","response_time":59,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["args","argv","cli","cli-flags","command-line","flags","minimist","parser","yargs"],"created_at":"2024-07-31T19:01:02.569Z","updated_at":"2025-10-09T18:23:27.765Z","avatar_url":"https://github.com/lukeed.png","language":"JavaScript","readme":"# mri [![CI](https://github.com/lukeed/mri/workflows/CI/badge.svg?branch=master\u0026event=push)](https://github.com/lukeed/mri/actions) [![licenses](https://licenses.dev/b/npm/mri)](https://licenses.dev/npm/mri)\n\n\u003e 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//=\u003e { _: ['hello', 'world'], foo:true, bar:'baz', m:true, t:true, v:true }\n\nmri(argv, { boolean:['bar'] });\n//=\u003e { _: ['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//=\u003e { _: ['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`\u003cbr\u003e\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`\u003cbr\u003e\nDefault: `{}`\n\nAn object of keys whose values are `String`s or `Array\u003cString\u003e` of aliases. These will be added to the parsed output with matching values.\n\n#### options.boolean\nType: `Array|String`\u003cbr\u003e\nDefault: `[]`\n\nA single key (or array of keys) that should be parsed as `Boolean`s.\n\n#### options.default\nType: `Object`\u003cbr\u003e\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//=\u003e { _:[], foo:'bar' }\n\nmri(['--foo', 'bar'], {\n  default: { foo:true, baz:'hello', bat:42 }\n});\n//=\u003e { _:['bar'], foo:true, baz:'hello', bat:42 }\n```\n\n\u003e **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`\u003cbr\u003e\nDefault: `[]`\n\nA single key (or array of keys) that should be parsed as `String`s.\n\n#### options.unknown\nType: `Function`\u003cbr\u003e\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\u003e **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    //=\u003e { _:[], a:'', b:'', c:'hello' }\n\n    mri(['-abc', 'hello']);\n    //=\u003e { _:[], 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\u003e 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","funding_links":["https://github.com/sponsors/lukeed"],"categories":["JavaScript","Packages","cli","Uncategorized","Utilities"],"sub_categories":["Uncategorized","Command Line Interfaces (CLI)"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flukeed%2Fmri","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flukeed%2Fmri","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flukeed%2Fmri/lists"}