File tree 1 file changed +29
-0
lines changed
1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -156,3 +156,32 @@ const group = await p.group(
156
156
157
157
console .log (group .name , group .age , group .color );
158
158
```
159
+
160
+ ### Building
161
+
162
+ Just like ` group ` , but on ` builder ` way, so you can choose which one fits better.
163
+
164
+ ``` js
165
+ import * as p from ' @clack/prompts' ;
166
+
167
+ const results = await p
168
+ .builder ()
169
+ .add (' name' , () => p .text ({ message: ' What is your name?' }))
170
+ .add (' age' , () => p .text ({ message: ' What is your age?' }))
171
+ .add (' color' , ({ results }) =>
172
+ p .multiselect ({
173
+ message: ` What is your favorite color ${ results .name } ?` ,
174
+ options: [
175
+ { value: ' red' , label: ' Red' },
176
+ { value: ' green' , label: ' Green' },
177
+ { value: ' blue' , label: ' Blue' }
178
+ ]
179
+ })
180
+ )
181
+ .onCancel (() => {
182
+ p .cancel (' Builder canceled' );
183
+ process .exit (0 );
184
+ })
185
+ .run ();
186
+ console .log (results .name , results .age , results .color );
187
+ ```
You can’t perform that action at this time.
0 commit comments