{"id":25763883,"url":"https://github.com/bernankez/prompt","last_synced_at":"2026-05-11T12:36:25.430Z","repository":{"id":178201916,"uuid":"661484177","full_name":"Bernankez/prompt","owner":"Bernankez","description":"Effortlessly build beautiful command-line apps","archived":false,"fork":false,"pushed_at":"2024-01-12T02:08:50.000Z","size":109,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-15T01:18:15.896Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://clack.cc","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/Bernankez.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}},"created_at":"2023-07-03T01:25:58.000Z","updated_at":"2023-07-03T08:20:45.000Z","dependencies_parsed_at":"2024-01-12T06:26:19.916Z","dependency_job_id":null,"html_url":"https://github.com/Bernankez/prompt","commit_stats":null,"previous_names":["bernankez/prompt"],"tags_count":4,"template":false,"template_full_name":"Bernankez/TSTemplate","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Bernankez%2Fprompt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Bernankez%2Fprompt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Bernankez%2Fprompt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Bernankez%2Fprompt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Bernankez","download_url":"https://codeload.github.com/Bernankez/prompt/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240926512,"owners_count":19879763,"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":[],"created_at":"2025-02-26T20:19:32.146Z","updated_at":"2026-05-11T12:36:25.383Z","avatar_url":"https://github.com/Bernankez.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# @bernankez/prompt\n\n[![npm](https://img.shields.io/npm/v/@bernankez/prompt?color=red\u0026label=npm)](https://www.npmjs.com/package/@bernankez/prompt)\n[![CI](https://github.com/Bernankez/prompt/workflows/CI/badge.svg)](https://github.com/Bernankez/prompt/actions)\n\nForked from [@clack/prompts@0.6.3](https://github.com/natemoo-re/clack/tree/main/packages/prompts)\n\n### Install\n\n```sh\n$ pnpm add @bernankez/prompt\n```\n\n#### Changes in this fork\n- Improved type hints.\n- Add `format` option.\n```ts\nconst options = {\n  format(value: Value) {\n    return formatValue(value);\n  }\n};\n```\n- Call `onCancel` callback on every prompt if `onCancel` is registered.\n```ts\nonCancel((value) =\u003e {\n  if (isCancel(value)) {\n    cancel(\"Operation canceled\");\n    process.exit(0);\n  }\n});\n```\n- Exclude `symbol` from return type. If `onCancel` is not registered, you need to handle `isCancel` in `format` for every prompt. Or else, program will exit.\n```ts\nconst options = {\n  format(value: Value) {\n    if (isCancel(value)) {\n      // ...\n    }\n    return value;\n  }\n};\n```\n- Enhanced log parameter types\n```\nlog.message(619); // message can be a number\n```\n\n---\n\n# `@clack/prompts`\n\nEffortlessly build beautiful command-line apps 🪄 [Try the demo](https://stackblitz.com/edit/clack-prompts?file=index.js)\n\n![clack-prompt](https://github.com/natemoo-re/clack/blob/main/.github/assets/clack-demo.gif)\n\n---\n\n`@clack/prompts` is an opinionated, pre-styled wrapper around [`@clack/core`](https://www.npmjs.com/package/@clack/core).\n\n- 🤏 80% smaller than other options\n- 💎 Beautiful, minimal UI\n- ✅ Simple API\n- 🧱 Comes with `text`, `confirm`, `select`, `multiselect`, and `spinner` components\n\n## Basics\n\n### Setup\n\nThe `intro` and `outro` functions will print a message to begin or end a prompt session, respectively.\n\n```js\nimport { intro, outro } from \"@clack/prompts\";\n\nintro(\"create-my-app\");\n// Do stuff\noutro(\"You're all set!\");\n```\n\n### Cancellation\n\nThe `isCancel` function is a guard that detects when a user cancels a question with `CTRL + C`. You should handle this situation for each prompt, optionally providing a nice cancellation message with the `cancel` utility.\n\n```js\nimport { cancel, isCancel, text } from \"@clack/prompts\";\n\nconst value = await text(/* TODO */);\n\nif (isCancel(value)) {\n  cancel(\"Operation cancelled.\");\n  process.exit(0);\n}\n```\n\n## Components\n\n### Text\n\nThe text component accepts a single line of text.\n\n```js\nimport { text } from \"@clack/prompts\";\n\nconst meaning = await text({\n  message: \"What is the meaning of life?\",\n  placeholder: \"Not sure\",\n  initialValue: \"42\",\n  validate(value) {\n    if (value.length === 0) { return \"Value is required!\"; }\n  },\n});\n```\n\n### Confirm\n\nThe confirm component accepts a yes or no answer. The result is a boolean value of `true` or `false`.\n\n```js\nimport { confirm } from \"@clack/prompts\";\n\nconst shouldContinue = await confirm({\n  message: \"Do you want to continue?\",\n});\n```\n\n### Select\n\nThe select component allows a user to choose one value from a list of options. The result is the `value` prop of a given option.\n\n```js\nimport { select } from \"@clack/prompts\";\n\nconst projectType = await select({\n  message: \"Pick a project type.\",\n  options: [\n    { value: \"ts\", label: \"TypeScript\" },\n    { value: \"js\", label: \"JavaScript\" },\n    { value: \"coffee\", label: \"CoffeeScript\", hint: \"oh no\" },\n  ],\n});\n```\n\n### Multi-Select\n\nThe `multiselect` component allows a user to choose many values from a list of options. The result is an array with all selected `value` props.\n\n```js\nimport { multiselect } from \"@clack/prompts\";\n\nconst additionalTools = await multiselect({\n  message: \"Select additional tools.\",\n  options: [\n    { value: \"eslint\", label: \"ESLint\", hint: \"recommended\" },\n    { value: \"prettier\", label: \"Prettier\" },\n    { value: \"gh-action\", label: \"GitHub Action\" },\n  ],\n  required: false,\n});\n```\n\n### Spinner\n\nThe spinner component surfaces a pending action, such as a long-running download or dependency installation.\n\n```js\nimport { spinner } from \"@clack/prompts\";\n\nconst s = spinner();\ns.start(\"Installing via npm\");\n// Do installation\ns.stop(\"Installed via npm\");\n```\n\n## Utilities\n\n### Grouping\n\nGrouping prompts together is a great way to keep your code organized. This accepts a JSON object with a name that can be used to reference the group later. The second argument is an optional but has a `onCancel` callback that will be called if the user cancels one of the prompts in the group.\n\n```js\nimport * as p from \"@clack/prompts\";\n\nconst group = await p.group(\n  {\n    name: () =\u003e p.text({ message: \"What is your name?\" }),\n    age: () =\u003e p.text({ message: \"What is your age?\" }),\n    color: ({ results }) =\u003e\n      p.multiselect({\n        message: `What is your favorite color ${results.name}?`,\n        options: [\n          { value: \"red\", label: \"Red\" },\n          { value: \"green\", label: \"Green\" },\n          { value: \"blue\", label: \"Blue\" },\n        ],\n      }),\n  },\n  {\n    // On Cancel callback that wraps the group\n    // So if the user cancels one of the prompts in the group this function will be called\n    onCancel: ({ results }) =\u003e {\n      p.cancel(\"Operation cancelled.\");\n      process.exit(0);\n    },\n  }\n);\n\nconsole.log(group.name, group.age, group.color);\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbernankez%2Fprompt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbernankez%2Fprompt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbernankez%2Fprompt/lists"}