-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathindex.ts
50 lines (41 loc) · 1.6 KB
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// Import Internal Dependencies
import * as prompts from "./src/prompts/index.js";
import { required, type PromptValidator } from "./src/validators.js";
import { PromptAgent } from "./src/prompt-agent.js";
import type { AbstractPromptOptions } from "./src/prompts/abstract.js";
import type { Choice } from "./src/types.js";
import type { QuestionOptions } from "./src/prompts/question.js";
import type { ConfirmOptions } from "./src/prompts/confirm.js";
import type { MultiselectOptions } from "./src/prompts/multiselect.js";
import type { SelectOptions } from "./src/prompts/select.js";
export function question(message: string, options: Omit<QuestionOptions, "message"> = {}) {
return new prompts.QuestionPrompt({ ...options, message }).question();
}
export function select<T extends string>(message: string, options: Omit<SelectOptions<T>, "message">) {
const selectPrompt = new prompts.SelectPrompt({ ...options, message });
return selectPrompt.select() as Promise<T>;
}
export function confirm(message: string, options: Omit<ConfirmOptions, "message"> = {}) {
const confirmPrompt = new prompts.ConfirmPrompt({ ...options, message });
return confirmPrompt.confirm();
}
export function multiselect<T extends string>(
message: string,
options: Omit<MultiselectOptions<T>, "message">
) {
const multiselectPrompt = new prompts.MultiselectPrompt({ ...options, message });
return multiselectPrompt.multiselect() as Promise<T[]>;
}
export type {
PromptValidator,
AbstractPromptOptions,
QuestionOptions,
ConfirmOptions,
Choice,
MultiselectOptions,
SelectOptions
};
export {
required,
PromptAgent
};