{"id":13816788,"url":"https://github.com/TopCli/stdin","last_synced_at":"2025-05-15T18:32:30.569Z","repository":{"id":42570359,"uuid":"207160921","full_name":"TopCli/stdin","owner":"TopCli","description":"Node.js light ⚡, interactive and elegant input crafted for REPL experience.","archived":false,"fork":false,"pushed_at":"2024-02-01T01:11:42.000Z","size":211,"stargazers_count":10,"open_issues_count":5,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-11-07T00:47:28.283Z","etag":null,"topics":["cli","input","interactive","repl","stdin","tty"],"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/TopCli.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-09-08T19:13:46.000Z","updated_at":"2024-04-10T01:12:35.000Z","dependencies_parsed_at":"2023-02-10T10:45:49.797Z","dependency_job_id":"63d161f8-6958-4466-8602-d23421ff17d4","html_url":"https://github.com/TopCli/stdin","commit_stats":null,"previous_names":["slimio/stdin"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TopCli%2Fstdin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TopCli%2Fstdin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TopCli%2Fstdin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TopCli%2Fstdin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/TopCli","download_url":"https://codeload.github.com/TopCli/stdin/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225125723,"owners_count":17424717,"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":["cli","input","interactive","repl","stdin","tty"],"created_at":"2024-08-04T06:00:21.334Z","updated_at":"2025-05-15T18:32:30.562Z","avatar_url":"https://github.com/TopCli.png","language":"JavaScript","readme":"# Stdin\n![version](https://img.shields.io/badge/dynamic/json.svg?style=for-the-badge\u0026url=https://raw.githubusercontent.com/TopCli/stdin/master/package.json\u0026query=$.version\u0026label=Version)\n[![Maintenance](https://img.shields.io/badge/Maintained%3F-yes-green.svg?style=for-the-badge)](https://github.com/TopCli/stdin/commit-activity)\n[![mit](https://img.shields.io/badge/License-MIT-green.svg?style=for-the-badge)](https://github.com/TopCli/stdin/blob/master/LICENSE)\n[![OpenSSF\nScorecard](https://api.securityscorecards.dev/projects/github.com/TopCli/stdin/badge?style=for-the-badge)](https://api.securityscorecards.dev/projects/github.com/TopCli/stdin)\n![build](https://img.shields.io/github/actions/workflow/status/TopCli/stdin/node.js.yml?style=for-the-badge)\n\nA lightweight and interactive standard input (stdin) utility for Node.js, designed for REPL-like experiences with support for auto-completion and history.\n\nInternally, it leverages `process.stdin` in raw mode to capture key-by-key input directly from the TTY stream.\n\n\u003cp align=\"center\"\u003eDemo with the SlimIO CLI\u003cp\u003e\n\u003cp align=\"center\"\u003e\n\u003cimg src=\"https://i.imgur.com/t18LDhm.gif\"\u003e\n\u003c/p\u003e\n\n## Requirements\n- [Node.js](https://nodejs.org/en/) v22 or higher\n\n## Getting Started\n\nThis package is available in the Node Package Repository and can be easily installed with [npm](https://docs.npmjs.com/getting-started/what-is-npm) or [yarn](https://yarnpkg.com).\n\n```bash\n$ npm i @topcli/stdin\n# or\n$ yarn add @topcli/stdin\n```\n\n## Usage example\n```js\nimport stdin from \"@topcli/stdin\";\n\nconst data = await stdin(\"Question title \u003e \", {\n  history: [\"command in history 1\", \"command in history 2\"],\n  autocomplete: [\n    \"events\",\n    \"events.get_info\"\n  ]\n});\nconsole.log(`input data: ${data}`);\n```\n\n\u003e [!TIP]\n\u003e The history array is passed by reference. If you plan to run multiple prompts in a loop, define a shared history array outside the loop to persist input history across calls.\n\n## API\n\n### stdin(title: null | string, options?: StdinOptions): Promise\u003c string \u003e\n\nPrompts the user for input with an optional title and options. If **title** is `null`, the prompt will be displayed without a prefix.\n\n`StdinOptions` interface\n\n```ts\ninterface StdinOptions {\n  /**\n   * An array of previous commands or inputs to enable navigation with arrow keys.\n   */\n  history?: string[];\n  /**\n   * A list of strings used to suggest autocompletion while typing.\n   */\n  autocomplete?: string[];\n}\n```\n\n\u003e [!CAUTION]\n\u003e This module does not implement history persistence or caching. If you want to persist history across sessions, consider using a package like [cacache](https://github.com/npm/cacache#readme).\n\n## Contributors ✨\n\n\u003c!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section --\u003e\n[![All Contributors](https://img.shields.io/badge/all_contributors-3-orange.svg?style=flat-square)](#contributors-)\n\u003c!-- ALL-CONTRIBUTORS-BADGE:END --\u003e\n\nThanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):\n\n\u003c!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section --\u003e\n\u003c!-- prettier-ignore-start --\u003e\n\u003c!-- markdownlint-disable --\u003e\n\u003ctable\u003e\n  \u003ctbody\u003e\n    \u003ctr\u003e\n      \u003ctd align=\"center\" valign=\"top\" width=\"14.28%\"\u003e\u003ca href=\"https://www.linkedin.com/in/thomas-gentilhomme/\"\u003e\u003cimg src=\"https://avatars.githubusercontent.com/u/4438263?v=4?s=100\" width=\"100px;\" alt=\"Gentilhomme\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eGentilhomme\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"https://github.com/TopCli/stdin/commits?author=fraxken\" title=\"Code\"\u003e💻\u003c/a\u003e \u003ca href=\"https://github.com/TopCli/stdin/commits?author=fraxken\" title=\"Documentation\"\u003e📖\u003c/a\u003e \u003ca href=\"https://github.com/TopCli/stdin/pulls?q=is%3Apr+reviewed-by%3Afraxken\" title=\"Reviewed Pull Requests\"\u003e👀\u003c/a\u003e \u003ca href=\"#security-fraxken\" title=\"Security\"\u003e🛡️\u003c/a\u003e \u003ca href=\"https://github.com/TopCli/stdin/issues?q=author%3Afraxken\" title=\"Bug reports\"\u003e🐛\u003c/a\u003e\u003c/td\u003e\n      \u003ctd align=\"center\" valign=\"top\" width=\"14.28%\"\u003e\u003ca href=\"https://github.com/AlexandreMalaj\"\u003e\u003cimg src=\"https://avatars.githubusercontent.com/u/32218832?v=4?s=100\" width=\"100px;\" alt=\"Alexandre Malaj\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eAlexandre Malaj\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"https://github.com/TopCli/stdin/commits?author=AlexandreMalaj\" title=\"Code\"\u003e💻\u003c/a\u003e \u003ca href=\"https://github.com/TopCli/stdin/commits?author=AlexandreMalaj\" title=\"Documentation\"\u003e📖\u003c/a\u003e\u003c/td\u003e\n      \u003ctd align=\"center\" valign=\"top\" width=\"14.28%\"\u003e\u003ca href=\"https://github.com/PierreDemailly\"\u003e\u003cimg src=\"https://avatars.githubusercontent.com/u/39910767?v=4?s=100\" width=\"100px;\" alt=\"PierreDemailly\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003ePierreDemailly\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"https://github.com/TopCli/stdin/commits?author=PierreDemailly\" title=\"Code\"\u003e💻\u003c/a\u003e \u003ca href=\"https://github.com/TopCli/stdin/commits?author=PierreDemailly\" title=\"Tests\"\u003e⚠️\u003c/a\u003e\u003c/td\u003e\n    \u003c/tr\u003e\n  \u003c/tbody\u003e\n\u003c/table\u003e\n\n\u003c!-- markdownlint-restore --\u003e\n\u003c!-- prettier-ignore-end --\u003e\n\n\u003c!-- ALL-CONTRIBUTORS-LIST:END --\u003e\n\n## License\nMIT\n","funding_links":[],"categories":["Packages"],"sub_categories":["CLI (TTY etc..)"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FTopCli%2Fstdin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FTopCli%2Fstdin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FTopCli%2Fstdin/lists"}