{"id":16127501,"url":"https://github.com/hildjj/minus-h","last_synced_at":"2025-03-18T14:30:28.023Z","repository":{"id":172860542,"uuid":"649873722","full_name":"hildjj/minus-h","owner":"hildjj","description":"Add help generation to APIs created with Node's util.parseArgs function","archived":false,"fork":false,"pushed_at":"2024-08-08T21:59:07.000Z","size":201,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-02-28T10:03:13.923Z","etag":null,"topics":["help","node","nodejs","parseargs","unicode","word-wrap"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/hildjj.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-06-05T20:38:00.000Z","updated_at":"2024-08-08T21:58:12.000Z","dependencies_parsed_at":null,"dependency_job_id":"18f83fe9-1ed2-49cc-b876-224b8a8ca498","html_url":"https://github.com/hildjj/minus-h","commit_stats":null,"previous_names":["hildjj/minus-h"],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hildjj%2Fminus-h","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hildjj%2Fminus-h/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hildjj%2Fminus-h/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hildjj%2Fminus-h/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hildjj","download_url":"https://codeload.github.com/hildjj/minus-h/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243933378,"owners_count":20370989,"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","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":["help","node","nodejs","parseargs","unicode","word-wrap"],"created_at":"2024-10-09T21:44:23.917Z","updated_at":"2025-03-18T14:30:27.750Z","avatar_url":"https://github.com/hildjj.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# minus-h\n\nAdd help generation to APIs created with Node's\n[util.parseArgs()](https://nodejs.org/api/util.html#utilparseargsconfig)\nfunction.\n\n## Installation\n\n```sh\nnpm install minus-h\n```\n\n### API\n\n`parseArgsWithHelp()` is a function that wraps `util.parseArgs()`, adding\na \"-h,--help\" argument.  It takes one or two arguments.  The first argument is\nan augmented version of the options passed to `util.parseArgs()`, with\ndescriptions provided for options as well as the command as a whole.  The second\noptional argument is [options](https://github.com/cto-af/linewrap#options) for\nline wrapping.  The wrapping width defaults to your terminal width (via\n[process.stdout.columns](https://nodejs.org/api/tty.html#writestreamcolumns)).\n\n```js\nimport {parseArgsWithHelp} from 'minus-h'\n\nparseArgsWithHelp({\n  description: 'A command that does something very interesting',\n  argumentName: 'files',\n  argumentDescription: 'the files to be processed',\n  allowPositionals: true,\n  options: {\n    encoding: {\n      type: 'string',\n      argumentName: 'encoding',\n      description: 'encoding for files read or written',\n      choices: [\"utf8\", \"base64\"]\n    },\n  },\n}, { width: 80 })\n```\n\n`node example.js --help` outputs the following to stderr, before exiting with\nexit code 64:\n\n```\nUsage: example [options] [files]\n\nA command that does something very interesting\n\nArguments:\n  files                  the files to be processed\n\nOptions:\n  --encoding \u003cencoding\u003e  encoding for files read or written (choices: \"utf8\",\n                         \"base64\") Default: \"utf8\"\n  -h,--help              display help for command\n```\n\nThe `usage()` function takes the same two parameters.  It always writes\nhelp information to output, then exits.  It is useful if you've detected a\nhigher level error condition with your input parameters, and want to re-iterate\nthe usage information to users as if they had used `--help`.\n\n## Testing\n\nTwo more parameters may be added to the configuration parameter:\n\n- `outputStream`: a writable stream to write the help text to.  Defaults to\n  `process.stderr`.  Only the `write` method is ever called.\n- `exit()`: a function that takes a number that is called when output is\n   complete.  Defaults to `process.exit`.\n\nThese options are useful during testing so that you can catch the help text\nthat would have been written, and prevent your test harness from actually\nexiting.\n\n---\n[![Tests](https://github.com/hildjj/minus-h/actions/workflows/node.js.yml/badge.svg)](https://github.com/hildjj/minus-h/actions/workflows/node.js.yml)\n[![codecov](https://codecov.io/gh/hildjj/minus-h/branch/main/graph/badge.svg?token=QQNMTT4XJQ)](https://codecov.io/gh/hildjj/minus-h)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhildjj%2Fminus-h","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhildjj%2Fminus-h","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhildjj%2Fminus-h/lists"}