[READ-ONLY] Mirror of https://github.com/bombshell-dev/clack. Effortlessly build beautiful command-line apps bomb.sh/docs/clack/basics/getting-started/
cli command-line command-line-app node prompt prompts
5

Configure Feed

Select the types of activity you want to include in your feed.

[ci] format

authored by

natemoo-re and committed by
github-actions[bot]
(Feb 17, 2023, 2:31 PM UTC) c2dbd27c 94a46ac1

+24 -21
+24 -21
packages/prompts/README.md
··· 128 128 Grouping 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. 129 129 130 130 ```js 131 - import * as p from '@clack/prompts' 131 + import * as p from '@clack/prompts'; 132 132 133 - const group = await p.group({ 134 - name: () => p.text({ message: "What is your name?" }), 135 - age: () => p.text({ message: "What is your age?" }), 136 - color: ({ results }) => p.multiselect({ 137 - message: `What is your favorite color ${results.name}?`, 138 - options: [ 139 - { value: 'red', label: 'Red' }, 140 - { value: 'green', label: 'Green' }, 141 - { value: 'blue', label: 'Blue' }, 142 - ], 143 - }) 144 - }, 145 - { 146 - // On Cancel callback that wraps the group 147 - // So if the user cancels one of the prompts in the group this function will be called 148 - onCancel: ({ results }) => { 149 - p.cancel('Operation cancelled.') 150 - process.exit(0) 133 + const group = await p.group( 134 + { 135 + name: () => p.text({ message: 'What is your name?' }), 136 + age: () => p.text({ message: 'What is your age?' }), 137 + color: ({ results }) => 138 + p.multiselect({ 139 + message: `What is your favorite color ${results.name}?`, 140 + options: [ 141 + { value: 'red', label: 'Red' }, 142 + { value: 'green', label: 'Green' }, 143 + { value: 'blue', label: 'Blue' }, 144 + ], 145 + }), 146 + }, 147 + { 148 + // On Cancel callback that wraps the group 149 + // So if the user cancels one of the prompts in the group this function will be called 150 + onCancel: ({ results }) => { 151 + p.cancel('Operation cancelled.'); 152 + process.exit(0); 153 + }, 151 154 } 152 - }) 155 + ); 153 156 154 - console.log(group.name, group.age, group.color) 157 + console.log(group.name, group.age, group.color); 155 158 ```