{"name":"@clack/prompts","version":"0.2.2","keywords":["ask","clack","cli","command-line","command","input","interact","interface","menu","prompt","prompts","stdin","ui"],"author":{"url":"https://twitter.com/n_moore","name":"Nate Moore","email":"nate@natemoo.re"},"license":"MIT","_id":"@clack/prompts@0.2.2","maintainers":[{"name":"natemoo-re","email":"nate@natemoo.re"}],"homepage":"https://github.com/natemoo-re/clack/tree/main/packages/prompts#readme","bugs":{"url":"https://github.com/natemoo-re/clack/issues"},"dist":{"shasum":"8394ce2f33120cb79bd1fe74b40aa7cbf083564e","tarball":"http://registry-npm.ywwl.com/@clack/prompts/download/@clack/prompts-0.2.2.tgz","fileCount":7,"integrity":"sha512-Jtxq+sLkn3/4swLzGUvhKkgcHYh1XWgwq90RWY3KPWegSI4Aun4WDlHpQakIIeEJSg96Ip+keTJt3g02lUmKWw==","signatures":[{"sig":"MEUCIFzDXpqANSuzZIScbsA3BEoEelG33RTQ5qXS55F1htoaAiEAkoIhEtb6/LRAEqdppb5iuGlw1CJstol5bp9IQSH7xDg=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":21162,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj669GACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmoFSA/8CM3i4gn1dgGe6HeWnAU0IzRc3Kzbjax6khyl/CJNsf6ogC+W\r\nqVNQTx+s5Fa41r4r7fqWCPu2YbG3ioGxWBX139qblO3i2UYYuClOxZiz1AjM\r\ndGmyydyhQ52Eyk/SDgf75xrRal1KTXbJ3D10sP2JL5yYjqCjWVHjRco4oGLj\r\nYuhbSX9PZm3O7jOLItvvQam10RDAC328hOXZzPmIPF4unXpZ8nshUmv41HQi\r\nKl03+SOhIPRs5gNu36t4Ee/QJNWPlpfESTCxJdC+tV3cw5FP0GaqA7rvItrM\r\nAzDyeDSLVTiSF0jA1qjxAtjzN0sx+Lay480XGk06xoOorZZJDn4RGdsm8W2N\r\n1E/B51yNjsC546jvXyVw51wRtumCOnrPEtLqeDjlJc780Au+k1xlRkEPNSxy\r\nPy0enGex9NmBFlI7zN/0+eebDGzqLS/7ZOhIiLD0C4E8WOmoiaDmLDKQ50zB\r\nGAG13+gNXm/I3cKlGa56pi4Fy3iJvcVdWY1RWBDEO3SUYe9MgocIBXYSTueM\r\nbG/+QOr/f2xRp+Y9oNRcizu+Oioy17B2X0dcO9X5tmBLRyKwp6u1V0sEXyTM\r\nvXjqxZB7AIJ4vtkGp1hFowuQMoFgffkhCXy2CI+7BdqtGC5O4IhZ6Xg+1Nml\r\nbB+eMUg1T3aLN7Q4xIpQl4LwQ9/zGC//4uU=\r\n=vycc\r\n-----END PGP SIGNATURE-----\r\n","size":6297,"noattachment":false,"key":"/@clack/prompts/-/@clack/prompts-0.2.2.tgz"},"main":"./dist/index.cjs","type":"module","_from":"file:clack-prompts-0.2.2.tgz","types":"./dist/index.d.ts","module":"./dist/index.mjs","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","require":"./dist/index.cjs"},"./package.json":"./package.json"},"scripts":{},"_npmUser":{"name":"natemoo-re","email":"nate@natemoo.re"},"_resolved":"/tmp/4377d9f284612d5ef5182856ac9e6e87/clack-prompts-0.2.2.tgz","_integrity":"sha512-Jtxq+sLkn3/4swLzGUvhKkgcHYh1XWgwq90RWY3KPWegSI4Aun4WDlHpQakIIeEJSg96Ip+keTJt3g02lUmKWw==","repository":{"url":"git+https://github.com/natemoo-re/clack.git","type":"git","directory":"packages/prompts"},"_npmVersion":"9.3.1","description":"Effortlessly build beautiful command-line apps 🪄 [Try the demo](https://stackblitz.com/edit/clack-prompts?file=index.js)","directories":{},"_nodeVersion":"18.14.0","dependencies":{"picocolors":"^1.0.0","sisteransi":"^1.0.5","@clack/core":"^0.1.3"},"_hasShrinkwrap":false,"packageManager":"pnpm@7.6.0","devDependencies":{"unbuild":"^1.1.1"},"_npmOperationalInternal":{"tmp":"tmp/prompts_0.2.2_1676390214538_0.7403544891288856","host":"s3://npm-registry-packages"},"readme":"# `@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/bombshell-dev/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`, `password`, `confirm`, `date`, `select`, `autocomplete`, `selectKey`, `multiselect`, `path`, 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 { isCancel, cancel, text } from '@clack/prompts';\n\nconst value = await text({\n  message: 'What is the meaning of life?',\n});\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### Password\n\nThe password prompt behaves like the [`text`](#text) prompt, but masks the input as the user types.\n\n```js\nimport { password } from '@clack/prompts';\n\nconst secret = await password({\n  message: 'Set a password.',\n  mask: '*',\n  validate(value) {\n    if (!value || value.length < 8) return 'Password must be at least 8 characters.';\n  },\n});\n```\n\n### Confirm\n\nThe `confirm` prompt accepts a yes or no choice, returning a boolean value corresponding to the user's selection.\n\n```js\nimport { confirm } from '@clack/prompts';\n\nconst shouldContinue = await confirm({\n  message: 'Do you want to continue?',\n});\n```\n\n### Date\n\nThe `date` prompt provides an interactive date picker, allowing users to navigate between year, month, and day segments and increment/decrement values using keyboard controls.\n\n```js\nimport { date } from '@clack/prompts';\n\nconst birthday = await date({\n  message: 'Pick your birthday',\n  minDate: new Date('1900-01-01'),\n  initialValue: new Date(),\n  maxDate: new Date(),\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', disabled: true },\n    { value: 'coffee', label: 'CoffeeScript', hint: 'oh no' },\n  ],\n});\n```\n\n### Autocomplete\n\nThe `autocomplete` prompt combines text input with a searchable list of options. It's perfect for when you have a large list of options and want to help users find what they're looking for quickly.\n\n```js\nimport { autocomplete } from '@clack/prompts';\n\nconst framework = await autocomplete({\n  message: 'Pick a framework.',\n  placeholder: 'Type to search...',\n  options: [\n    { value: 'next', label: 'Next.js' },\n    { value: 'nuxt', label: 'Nuxt' },\n    { value: 'sveltekit', label: 'SvelteKit' },\n    { value: 'remix', label: 'Remix' },\n  ],\n});\n```\n\n### Autocomplete Multi-Select\n\nThe `autocompleteMultiselect` prompt combines the search functionality of [autocomplete](#autocomplete) with the ability to select multiple options.\n\n```js\nimport { autocomplete } from '@clack/prompts';\n\nconst framework = await autocomplete({\n  message: 'Search for a framework',\n  options: [\n    { value: 'next', label: 'Next.js', hint: 'React framework' },\n    { value: 'astro', label: 'Astro', hint: 'Content-focused' },\n    { value: 'svelte', label: 'SvelteKit', hint: 'Compile-time framework' },\n    { value: 'remix', label: 'Remix', hint: 'Full stack framework' },\n    { value: 'nuxt', label: 'Nuxt', hint: 'Vue framework' },\n  ],\n  placeholder: 'Type to search...',\n  maxItems: 5,\n});\n```\n\n### Select Key\n\nThe `selectKey` component lets a user choose an option by pressing its single-character string `value` key directly.\n\n```js\nimport { selectKey } from '@clack/prompts';\n\nconst action = await selectKey({\n  message: 'Pick an action.',\n  options: [\n    { value: 'd', label: 'Deploy' },\n    { value: 't', label: 'Run tests' },\n    { value: 'q', label: 'Quit' },\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', disabled: true },\n    { value: 'gh-action', label: 'GitHub Action' },\n  ],\n  required: false,\n});\n```\n\nIt is also possible to select multiple items arranged into hierarchy by using `groupMultiselect`:\n\n```js\nimport { groupMultiselect } from '@clack/prompts';\n\nconst basket = await groupMultiselect({\n  message: 'Select your favorite fruits and vegetables:',\n  options: {\n    fruits: [\n      { value: 'apple', label: 'apple' },\n      { value: 'banana', label: 'banana' },\n      { value: 'cherry', label: 'cherry' },\n    ],\n    vegetables: [\n      { value: 'carrot', label: 'carrot' },\n      { value: 'spinach', label: 'spinach' },\n      { value: 'potato', label: 'potato' },\n    ]\n  }\n});\n```\n\n### Multi-Line Text\n\nThe multi-line prompt accepts multiple lines of text input. By default, pressing `Enter` twice submits the input.\n\n```js\nimport { multiline } from '@clack/prompts';\n\nconst bio = await multiline({\n  message: 'Tell us about yourself.',\n  placeholder: 'Start typing...',\n  validate(value) {\n    if (value.length === 0) return `value is required`;\n  },\n});\n```\n\nSet `showSubmit` to display an explicit submit button instead of double `Enter` submission:\n\n```js\nconst bio = await multiline({\n  message: 'Tell us about yourself.',\n  showSubmit: true,\n});\n```\n\n### Path\n\nThe `path` prompt extends [`autocomplete`](#autocomplete) to provide file and directory suggestions.\n\n```js\nimport { path } from '@clack/prompts';\n\nconst targetDir = await path({\n  message: 'Select an existing directory.',\n  directory: true,\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 here\ns.stop('Installed via npm');\n```\n\n### Progress\n\nThe progress component extends the spinner component to add a progress bar to visualize the progression of an action.\n\n```js\nimport { progress } from '@clack/prompts';\n\nconst p = progress({ max: 10 });\np.start('Downloading archive');\n// Do download here\np.advance(3, 'Downloading (30%)');\n// ...\np.advance(5, 'Downloading (80%)');\n// ...\np.stop('Archive downloaded');\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: () => p.text({ message: 'What is your name?' }),\n    age: () => p.text({ message: 'What is your age?' }),\n    color: ({ results }) =>\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 }) => {\n      p.cancel('Operation cancelled.');\n      process.exit(0);\n    },\n  }\n);\n\nconsole.log(group.name, group.age, group.color);\n```\n\n### Tasks\n\nExecute multiple tasks in spinners.\n\n```js\nimport { tasks } from '@clack/prompts';\n\nawait tasks([\n  {\n    title: 'Installing via npm',\n    task: async (message) => {\n      // Do installation here\n      return 'Installed via npm';\n    },\n  },\n]);\n```\n\n### Logs\n\n```js\nimport { log } from '@clack/prompts';\n\nlog.info('Info!');\nlog.success('Success!');\nlog.step('Step!');\nlog.warn('Warn!');\nlog.error('Error!');\nlog.message('Hello, World', { symbol: color.cyan('~') });\n```\n\n\n### Stream\n\nWhen interacting with dynamic LLMs or other streaming message providers, use the `stream` APIs to log messages from an iterable, even an async one.\n\n```js\nimport { stream } from '@clack/prompts';\n\nstream.info((function *() { yield 'Info!'; })());\nstream.success((function *() { yield 'Success!'; })());\nstream.step((function *() { yield 'Step!'; })());\nstream.warn((function *() { yield 'Warn!'; })());\nstream.error((function *() { yield 'Error!'; })());\nstream.message((function *() { yield 'Hello'; yield \", World\" })(), { symbol: color.cyan('~') });\n```\n\n![clack-log-prompts](https://github.com/bombshell-dev/clack/blob/main/.github/assets/clack-logs.png)\n\n### Task Log\n\nWhen executing a sub-process or a similar sub-task, `taskLog` can be used to render the output continuously and clear it at the end if it was successful.\n\n```js\nimport { taskLog } from '@clack/prompts';\n\nconst log = taskLog({\n\ttitle: 'Running npm install'\n});\n\nfor await (const line of npmInstall()) {\n\tlog.message(line);\n}\n\nif (success) {\n\tlog.success('Done!');\n} else {\n\tlog.error('Failed!');\n}\n```\n","publish_time":1676390214822,"_cnpm_publish_time":1676390214822,"dist-tags":{"alpha":"1.0.0-alpha.10","latest":"1.8.1"}}