{"id":23814244,"url":"https://github.com/stuartpb/grarg","last_synced_at":"2026-06-18T12:32:30.951Z","repository":{"id":35027803,"uuid":"198123774","full_name":"stuartpb/grarg","owner":"stuartpb","description":"A bring-your-own-logic command-line-argument parser for Node.","archived":false,"fork":false,"pushed_at":"2022-03-24T09:04:00.000Z","size":15,"stargazers_count":1,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-09-26T01:18:46.659Z","etag":null,"topics":[],"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/stuartpb.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-07-22T01:20:48.000Z","updated_at":"2023-03-04T05:20:30.000Z","dependencies_parsed_at":"2022-08-08T04:00:47.893Z","dependency_job_id":null,"html_url":"https://github.com/stuartpb/grarg","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/stuartpb/grarg","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stuartpb%2Fgrarg","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stuartpb%2Fgrarg/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stuartpb%2Fgrarg/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stuartpb%2Fgrarg/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stuartpb","download_url":"https://codeload.github.com/stuartpb/grarg/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stuartpb%2Fgrarg/sbom","scorecard":{"id":856071,"data":{"date":"2025-08-11","repo":{"name":"github.com/stuartpb/grarg","commit":"5a63fa4978c5c92d73b75e51b1e570027c77e001"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":2.4,"checks":[{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"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":-1,"reason":"No tokens found","details":null,"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":"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":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","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":"Code-Review","score":0,"reason":"Found 0/4 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":"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":"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":"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":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE: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":"Vulnerabilities","score":5,"reason":"5 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-v6h2-p8h4-qcjw","Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3","Warn: Project is vulnerable to: GHSA-vh95-rmgr-6w4m","Warn: Project is vulnerable to: GHSA-xvch-5gv4-984h","Warn: Project is vulnerable to: GHSA-hj48-42vr-x3v9"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-23T23:55:15.601Z","repository_id":35027803,"created_at":"2025-08-23T23:55:15.601Z","updated_at":"2025-08-23T23:55:15.601Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34491228,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-18T02:00:06.871Z","response_time":128,"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":[],"created_at":"2025-01-02T03:46:58.648Z","updated_at":"2026-06-18T12:32:30.929Z","avatar_url":"https://github.com/stuartpb.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# grarg\n\n\u003e **\u0026ldquo;Grr. Argh.\u0026rdquo;** \u0026ndash; [Mutant Enemy](https://www.youtube.com/watch?v=H7alErR8cAE)\n\ngrarg is a minimal bring-your-own-logic parser for command-line arguments.\n\n## Why? What makes you think Node.js needs *another* argument parsing library?\n\nBecause every existing argument parser in the npm.com registry (or at least, all the ones I could find) follows the same flawed model. Not all command line arguments are map keys, and not all \"bare\" arguments are sequential. Many applications are better suited to a sort of state-machine argument parsing model, where options transform a state that determines how successive non-options are parsed.\n\nFor example, say you have a command like `chug package --verbose --env production --images foo.png bar.png --rescale=50% huge.png --scripts --minify index.js helper.js update-and-push`. It's pretty clear how this command would interpret these arguments, but there's no clean way to express it in a model like the one used by [minimist](https://www.npmjs.com/package/minimist) (or its successors like yargs/getopts/caproal/mri).\n\nWith `grarg`, you can write your own option-by-option parsing logic with an iterative callback that takes options and values as a series of (sometimes partial) pairs.\n\n## API: grarg([argv,] [params,] cb)\n\nThe `grarg` function returned by `require('grarg')` takes an array of arguments (`argv`), an object of parameters (`params` - not yet implemented), and a function to call back with option/value pairs (`cb`).\n\n`argv` defaults to `process.argv.slice(2)` by default. For most scripts, this is what you want. (If running in a binary-is-the-script environment like Electron, where there's no script name to chop off the argv array, you'll want to explicitly use `process.argv.slice(1)` instead.)\n\n`params` effectively defaults to `{\"end\": \"--\"}` (though each parameter's default is considered individually if unspecified).\n\n## Callback signature\n\nIf an option begins with two hyphens, it will be passed to the callback as the first parameter (with those double-hyphens stripped).\n\nIf an option is followed by a value (either as a pair like `--foo bar` or with an equals sign like `--foo=bar`), the option and its accompanyng value are passed to the callback as its first and second parameters, respectively.\n\nNote that this means `--foo=bar` is indistinguishable from `--foo bar`. If you support the first form, you ought to support the second form as an alternative syntax for the same specification: any kind of cleverness with differing behavior between the forms is user-hostile and unsupported.\n\nAlso note that this means you may get an option that is unrelated to the argument following it: for example, `shred --quickly buster.dat lindsay.dat` would be parsed as `cb(null, \"shred\")`, `cb(\"quickly\",\"buster.dat\")`, and `cb(null, \"lindsay.dat\")`. It's up to your callback to interpret and handle values that may be attached this kind of \"unrelated\" argument: always remember to check if a \"standalone value\" has been provided alongside any \"standalone option\".\n\nIf an option is followed by *another option*, the \"standalone\" option is passed to the callback with `null` as its second parameter.\n\nIf multiple successive non-hyphen-prefixed options are encountered, they will be passed to the callback with `null` as the first parameter.\n\nFor example, the command in the \"Why?\" section above, if passed to `grarg((k,v)=\u003econsole.log(JSON.stringify([k,v])))`, would look like:\n\n```js\n[null, \"chug\"]\n[null, \"package\"]\n[\"verbose\", null]\n[\"env\", \"production\"]\n[\"images\", \"foo.png\"]\n[null, \"bar.png\"]\n[\"rescale\", \"50%\"]\n[null, \"huge.png\"]\n[\"scripts\", null]\n[\"minify\", \"index.js\"]\n[null,\"helper.js\"]\n[null,\"update-and-push\"]\n```\n\n## The `end` parameter\n\n*Not yet implemented.*\n\nIf `end` is `\"--\"`, the first standalone `--` argument encountered in the input array will be passed to the callback as `cb(null, \"--\")`, and then all successive arguments will be passed to the callback with `null` as the first parameter, even if they appear to represent an option. (For example, `-- --foo=bar` would pass the second option as `cb(null, \"--foo=bar\")` and not `cb(\"foo\", \"bar\")`)).\n\nThis is generally used to define a list of arguments for a subprocess, like in the case of `ssh`, where `--` separates arguments to the SSH client SSH from arguments to a command to run on the host.\n\nIf `end` is a number, the first non-option argument after `end` number of non-options have been parsed will end argument parsing. A value of 1 will work like minimist's `stopEarly` (stopping parsing after the first non-option argument), and values of 2 and higher can be used to permit a number of positional arguments (such as commands or subcommands) before ceasing to parse options. (The value of 0 is reserved as a possible way to disable argument parsing altogether in certain circumstances.)\n\nIf `end` is `false`, any standalone `--` argument will be passed to the callback as `cb(null, \"--\")`, and paired parsing will continue. (To reuse an earlier example, the second argument of `-- --foo=bar` *would* be passed as `cb(\"foo\", \"bar\")` when `end` is `false`.).\n\nNote that this means a standalone `--` will *always* be interpreted as a standalone value, even when `end` is `false`. If you need to define `\"--\"` as the value of an option, you need to specify it using the `=` syntax, ie. `--foo=--` is the only way to get a parse result of `cb(\"foo\", \"--\")`. (Of course, this rule applies for *any* option-value that may begin with `--`, as longer strings would be interpreted as the beginning of a new option.)\n\n## The `short` parameter\n\n*Not yet implemented.*\n\nIf `params.short` is `true`, items starting with a single hyphen will be treated as options (ie. they will cause a prior option to be passed as `cb('--that-option',null)`), and passed to the callback with `'-'` as the first argument, and the rest of the item as the second argument (for example, `-xzf` would be passed to the callback as `cb('-','xzf')`).\n\nThis can interfere with negative numbers as values, so if `params.short` is `'nan'` (case-insensitive), this will only be applied if the argument does not evaluate to a number.\n\nIf `params.short` is `false` or undefined, arguments beginning with `-` are treated just like any other non-double-prefixed argument.\n\nNote that the single hyphen `-` is *always* treated as an ordinary argument.\n\nNote that, technically speaking, the call signature of short options with this parameter overlaps that of a triple-hyphen option, ie. `--- foo` is indistinguishable from `-foo`. If that's a problem for your use case, then don't use `short`.\n\n## Example usage\n\nHere's some code that uses `grargs` to implement `minimist`'s core default behavior in seven lines:\n\n```js\nconst args = {_:[]};\nrequire('grarg')((key, value) =\u003e {\n  key = key || '_';\n  if (value === null) value = true;\n  if (Array.isArray(args[key]) args[key].push(value);\n  else if (args[key] !== undefined) args[key] = [args[key], value];\n  else args[key] = value; });\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstuartpb%2Fgrarg","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstuartpb%2Fgrarg","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstuartpb%2Fgrarg/lists"}