{"id":23773386,"url":"https://github.com/beenotung/cli-helpers","last_synced_at":"2026-01-24T09:32:53.722Z","repository":{"id":257822364,"uuid":"867458738","full_name":"beenotung/cli-helpers","owner":"beenotung","description":"Helper library for building cli applications","archived":false,"fork":false,"pushed_at":"2024-10-12T00:37:47.000Z","size":17,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-26T19:59:46.339Z","etag":null,"topics":["cli","io","readline","typescript","utility"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/cli-helpers","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/beenotung.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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-10-04T05:32:07.000Z","updated_at":"2024-10-12T00:37:51.000Z","dependencies_parsed_at":null,"dependency_job_id":"f59dbfe9-20a1-4cec-a4c0-1a1b42bff6ab","html_url":"https://github.com/beenotung/cli-helpers","commit_stats":null,"previous_names":["beenotung/cli-helpers"],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/beenotung/cli-helpers","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/beenotung%2Fcli-helpers","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/beenotung%2Fcli-helpers/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/beenotung%2Fcli-helpers/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/beenotung%2Fcli-helpers/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/beenotung","download_url":"https://codeload.github.com/beenotung/cli-helpers/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/beenotung%2Fcli-helpers/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28723234,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-24T08:27:05.734Z","status":"ssl_error","status_checked_at":"2026-01-24T08:27:01.197Z","response_time":89,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["cli","io","readline","typescript","utility"],"created_at":"2025-01-01T05:39:34.738Z","updated_at":"2026-01-24T09:32:53.717Z","avatar_url":"https://github.com/beenotung.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# cli-helpers\n\nHelper library for building cli applications\n\n[![npm Package Version](https://img.shields.io/npm/v/cli-helpers)](https://www.npmjs.com/package/cli-helpers)\n\n## Features\n\n- **Multi-Line** I/O interface\n  - **async** `io.question(text)` for ease of use\n  - **buffered input** prevents data lost when pasting multi-line input\n  - **customizable I/O stream** using `process.stdin` and `process.stdout` as default\n  - **flushable buffer** to get pending input lines\n- Typescript support\n\n## Installation\n\n```bash\nnpm install cli-helpers\n```\n\nYou can also install `cli-helpers` with [pnpm](https://pnpm.io/), [yarn](https://yarnpkg.com/), or [slnpm](https://github.com/beenotung/slnpm)\n\n## Usage Example\n\n```typescript\nimport { createIO } from 'cli-helpers'\n\nasync function main() {\n  let io = createIO()\n  for (;;) {\n    let line = await io.question('\u003e ')\n    console.log('line:', line)\n    if (line == 'exit') {\n      break\n    }\n  }\n  io.close()\n}\n\nmain().catch(e =\u003e console.error(e))\n```\n\n## Typescript Signature\n\n\u003cdetails\u003e\n  \u003csummary\u003eio helper functions\u003c/summary\u003e\n\n```typescript\nimport { ReadLineOptions } from 'readline'\n\n/**\n * @description async io interface based on `readline.createInterface()`.\n * With internal buffer to avoid data lose when pasting multi-lines input.\n */\nexport function createIO(options?: {\n  input?: ReadLineOptions['input']\n  output?: ReadLineOptions['output']\n}): {\n  question: (question: string) =\u003e Promise\u003cstring\u003e\n  close: () =\u003e void\n  flush: () =\u003e string[]\n}\n```\n\n\u003c/details\u003e\n\u003cdetails\u003e\n  \u003csummary\u003efile helper functions\u003c/summary\u003e\n\n````typescript\n/**\n * @description look for the file from the given directory or parent directory recursively\n * @example\n * ```\n * let file = resolveFile({ dir: __dirname, filename: 'package.json' })\n * let pkg = readJSONFile(file)\n * ```\n */\nexport function resolveFile(args: { dir: string; filename: string }): string\n\n/**\n * @description read file as json data\n * @throws JSONFileError\n */\nexport function readJSONFile(file: string): any\n\n/**\n * @description write json data to file\n * @throws JSONFileError\n */\nexport function writeJSONFile(\n  file: string,\n  data: any,\n  options?: {\n    top_comment?: string\n    bottom_comment?: string\n  },\n): void\n\nexport class JSONFileError extends Error {\n  file: string\n}\n````\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003ejson helper functions\u003c/summary\u003e\n\n```typescript\n/**\n * @description remove comments from json text\n */\nexport function removeComments(text: string): string\n```\n\n\u003c/details\u003e\n\n## License\n\nThis project is licensed with [BSD-2-Clause](./LICENSE)\n\nThis is free, libre, and open-source software. It comes down to four essential freedoms [[ref]](https://seirdy.one/2021/01/27/whatsapp-and-the-domestication-of-users.html#fnref:2):\n\n- The freedom to run the program as you wish, for any purpose\n- The freedom to study how the program works, and change it so it does your computing as you wish\n- The freedom to redistribute copies so you can help others\n- The freedom to distribute copies of your modified versions to others\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbeenotung%2Fcli-helpers","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbeenotung%2Fcli-helpers","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbeenotung%2Fcli-helpers/lists"}