Skip to content

Variable: group ​

ts
const 
group
: <
T
>(
prompts
,
opts
?,
) =>
Promise
<
Prettify
<
PromptGroupAwaitedReturn
<
T
>>>;

Defined in: node_modules/.pnpm/@clack+prompts@1.9.0/node_modules/@clack/prompts/dist/index.d.mts:458

The group utility provides a consistent way to combine a series of prompts, combining each answer into one object. Each prompt receives the results of all previously completed prompts, and are displayed sequentially.

Type Parameters ​

Type Parameter

T

Parameters ​

ParameterType

prompts

PromptGroup<T>

opts?

PromptGroupOptions<T>

Returns ​

Promise<Prettify<PromptGroupAwaitedReturn<T>>>

See ​

https://bomb.sh/docs/clack/packages/prompts/#group

Example ​

ts
import { 
group
,
text
,
password
} from "@clack/prompts";
const
account
= await
group
({
email
: () =>
text
({
message
: "What is your email address?",
}),
username
: ({
results
}) =>
text
({
message
: "What is your username?",
placeholder
:
results
.email?.replace(/@.+$/, "").toLowerCase() ?? "",
}),
password
: () =>
password
({
message
: "Define your password",
}), });

基于 MIT 许可证发布