{"id":20206773,"url":"https://github.com/enquirer/prompt-expand","last_synced_at":"2025-04-10T12:33:10.604Z","repository":{"id":57331714,"uuid":"66805396","full_name":"enquirer/prompt-expand","owner":"enquirer","description":"List prompt, where the answer is selected using a shortcut. Can be used as a standalone prompt, or as a plugin for Enquirer.","archived":false,"fork":false,"pushed_at":"2018-03-21T16:22:57.000Z","size":92,"stargazers_count":4,"open_issues_count":3,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-24T11:13:10.671Z","etag":null,"topics":["ask","command-line","expand","prompt","question","terminal"],"latest_commit_sha":null,"homepage":"http://enquirer.io","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/enquirer.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}},"created_at":"2016-08-29T02:43:35.000Z","updated_at":"2019-04-01T00:52:45.000Z","dependencies_parsed_at":"2022-09-05T10:10:26.880Z","dependency_job_id":null,"html_url":"https://github.com/enquirer/prompt-expand","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/enquirer%2Fprompt-expand","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/enquirer%2Fprompt-expand/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/enquirer%2Fprompt-expand/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/enquirer%2Fprompt-expand/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/enquirer","download_url":"https://codeload.github.com/enquirer/prompt-expand/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248013161,"owners_count":21033316,"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":["ask","command-line","expand","prompt","question","terminal"],"created_at":"2024-11-14T05:25:59.679Z","updated_at":"2025-04-10T12:33:10.579Z","avatar_url":"https://github.com/enquirer.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# prompt-expand [![NPM version](https://img.shields.io/npm/v/prompt-expand.svg?style=flat)](https://www.npmjs.com/package/prompt-expand) [![NPM monthly downloads](https://img.shields.io/npm/dm/prompt-expand.svg?style=flat)](https://npmjs.org/package/prompt-expand) [![NPM total downloads](https://img.shields.io/npm/dt/prompt-expand.svg?style=flat)](https://npmjs.org/package/prompt-expand)\n\n\u003e Expand prompt. Can be used as a standalone prompt, or with a prompt system like [Enquirer](https://github.com/enquirer/enquirer).\n\n![prompt-expand example](https://raw.githubusercontent.com/enquirer/prompt-expand/master/example.gif)\n\n## Install\n\nInstall with [npm](https://www.npmjs.com/):\n\n```sh\n$ npm install --save prompt-expand\n```\n\n## Usage\n\n```js\nvar Prompt = require('prompt-expand');\nvar prompt = new Prompt({\n  message: 'What action should be taken on file.js?',\n  name: 'conflict',\n  default: 'x',\n  choices: [\n    {\n      key: 'y',\n      name: 'Overwrite',\n      value: 'overwrite'\n    },\n    {\n      key: 'a',\n      name: 'Overwrite this one and all next',\n      value: 'overwrite_all'\n    },\n    {\n      key: 'd',\n      name: 'Show diff',\n      value: 'diff'\n    },\n    new Prompt.Separator(),\n    {\n      key: 'x',\n      name: 'Abort',\n      value: 'abort'\n    }\n  ]\n});\n\n// async\nprompt.ask(function(answer) {\n  console.log({file: answer});\n});\n\n// promise\nprompt.run()\n  .then(function(answer) {\n    console.log({file: answer});\n  })\n  .catch(function(err) {\n    console.log(err);\n  });\n```\n\n## Enquirer usage\n\nRegister as a plugin with [enquirer](https://github.com/enquirer/enquirer).\n\n```js\nvar Enquirer = require('enquirer');\nvar enquirer = new Enquirer();\n\nenquirer.register('expand', require('prompt-expand'));\n```\n\n### Functional-style questions\n\nDefine questions using the `.question` method.\n\n```js\nenquirer.question('file', 'Conflict on `file.js`: ', {\n  type: 'expand',\n  // \"default\" can be the index of the default choice, \n  // or the `key` or `name` of the default choice\n  default: 'x', \n  choices: [\n    {\n      key: 'y',\n      name: 'Overwrite',\n      value: 'overwrite'\n    },\n    {\n      key: 'a',\n      name: 'Overwrite this one and all next',\n      value: 'overwrite_all'\n    },\n    {\n      key: 'd',\n      name: 'Show diff',\n      value: 'diff'\n    },\n    enquirer.separator(),\n    {\n      key: 'x',\n      name: 'Abort',\n      value: 'abort'\n    }\n  ]\n});\n\nenquirer.ask(questions)\n  .then(function(answers) {\n    console.log(answers);\n  })\n  .catch(function(err) {\n    console.log(err);\n  });\n```\n\n### Declarative-style questions\n\nDefine questions using a declarative, Inquirer-style format.\n\n```js\nvar questions = [\n  {\n    type: 'expand',\n    message: 'Conflict on `file.js`: ',\n    default: 'x',\n    name: 'file',\n    choices: [\n      {\n        key: 'y',\n        name: 'Overwrite',\n        value: 'overwrite'\n      },\n      {\n        key: 'a',\n        name: 'Overwrite this one and all next',\n        value: 'overwrite_all'\n      },\n      {\n        key: 'd',\n        name: 'Show diff',\n        value: 'diff'\n      },\n      enquirer.separator(),\n      {\n        key: 'x',\n        name: 'Abort',\n        value: 'abort'\n      }\n    ]\n  }\n];\n\nenquirer.ask(questions)\n  .then(function(answers) {\n    console.log(answers);\n  })\n  .catch(function(err) {\n    console.log(err);\n  });\n```\n\n## Attribution\n\nBased on the `expand` prompt in inquirer.\n\n## About\n\n### Related projects\n\n* [enquirer](https://www.npmjs.com/package/enquirer): Intuitive, plugin-based prompt system for node.js. Much faster and lighter alternative to Inquirer, with all… [more](https://github.com/enquirer/enquirer) | [homepage](https://github.com/enquirer/enquirer \"Intuitive, plugin-based prompt system for node.js. Much faster and lighter alternative to Inquirer, with all the same prompt types and more, but without the bloat.\")\n* [prompt-base](https://www.npmjs.com/package/prompt-base): Base prompt module used for creating custom prompts. | [homepage](https://github.com/enquirer/prompt-base \"Base prompt module used for creating custom prompts.\")\n* [prompt-checkbox](https://www.npmjs.com/package/prompt-checkbox): Multiple-choice/checkbox prompt. Can be used standalone or with a prompt system like [Enquirer](https://github.com/enquirer/enquirer). | [homepage](https://github.com/enquirer/prompt-checkbox \"Multiple-choice/checkbox prompt. Can be used standalone or with a prompt system like [Enquirer].\")\n* [prompt-confirm](https://www.npmjs.com/package/prompt-confirm): Confirm (yes/no) prompt. Can be used standalone or with a prompt system like [Enquirer](https://github.com/enquirer/enquirer). | [homepage](https://github.com/enquirer/prompt-confirm \"Confirm (yes/no) prompt. Can be used standalone or with a prompt system like [Enquirer].\")\n* [prompt-radio](https://www.npmjs.com/package/prompt-radio): Radio prompt. This prompt behaves like other radio-button interfaces, where only one choice is enabled… [more](https://github.com/enquirer/prompt-radio) | [homepage](https://github.com/enquirer/prompt-radio \"Radio prompt. This prompt behaves like other radio-button interfaces, where only one choice is enabled whilst all others are disabled. Can be used as a standalone prompt, or with a prompt system like [Enquirer].\")\n\n### Contributing\n\nPull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).\n\n### Running tests\n\nRunning and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:\n\n```sh\n$ npm install \u0026\u0026 npm test\n```\n\n### Author\n\n**Jon Schlinkert**\n\n* [github/jonschlinkert](https://github.com/jonschlinkert)\n* [twitter/jonschlinkert](https://twitter.com/jonschlinkert)\n\n### License\n\nCopyright © 2017, [Jon Schlinkert](https://github.com/jonschlinkert).\nReleased under the [MIT License](LICENSE).\n\n***\n\n_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.6.0, on May 27, 2017._","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fenquirer%2Fprompt-expand","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fenquirer%2Fprompt-expand","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fenquirer%2Fprompt-expand/lists"}