1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 | export = prompts;
|
11 |
|
12 | declare function prompts<T extends string = string>(
|
13 | questions: prompts.PromptObject<T> | Array<prompts.PromptObject<T>>,
|
14 | options?: prompts.Options
|
15 | ): Promise<prompts.Answers<T>>;
|
16 |
|
17 | declare namespace prompts {
|
18 |
|
19 | const prompt: any;
|
20 |
|
21 | function inject(obj: any): void;
|
22 |
|
23 | namespace inject {
|
24 | const prototype: {};
|
25 | }
|
26 |
|
27 | namespace prompts {
|
28 | function autocomplete(args: PromptObject): any;
|
29 |
|
30 | function confirm(args: PromptObject): void;
|
31 |
|
32 | function date(args: PromptObject): any;
|
33 |
|
34 | function invisible(args: PromptObject): any;
|
35 |
|
36 | function list(args: PromptObject): any;
|
37 |
|
38 | function multiselect(args: PromptObject): any;
|
39 |
|
40 | function number(args: PromptObject): void;
|
41 |
|
42 | function password(args: PromptObject): any;
|
43 |
|
44 | function select(args: PromptObject): void;
|
45 |
|
46 | function text(args: PromptObject): void;
|
47 |
|
48 | function toggle(args: PromptObject): void;
|
49 | }
|
50 |
|
51 | interface Choice {
|
52 | title: string;
|
53 | value: string;
|
54 | disable?: boolean;
|
55 | }
|
56 |
|
57 | interface Options {
|
58 | onSubmit?: (prompt: PromptObject, answer: any, answers: any[]) => void;
|
59 | onCancel?: (prompt: PromptObject, answers: any) => void;
|
60 | }
|
61 |
|
62 | interface PromptObject<T extends string = string> {
|
63 | type: ValueOrFunc<PromptType> | Falsy;
|
64 | name: ValueOrFunc<T>;
|
65 | message?: ValueOrFunc<string>;
|
66 | initial?: string | number | boolean | Date;
|
67 | style?: string;
|
68 | format?: PrevCaller<T, void>;
|
69 | validate?: PrevCaller<T, void>;
|
70 | onState?: PrevCaller<T, void>;
|
71 | min?: number;
|
72 | max?: number;
|
73 | float?: boolean;
|
74 | round?: number;
|
75 | increment?: number;
|
76 | seperator?: string;
|
77 | active?: string;
|
78 | inactive?: string;
|
79 | choices?: Choice[];
|
80 | hint?: string;
|
81 | suggest?: ((prev: any, values: any, prompt: PromptObject) => void);
|
82 | limit?: number;
|
83 | mask?: string;
|
84 | }
|
85 |
|
86 | type Answers<T extends string> = { [id in T]: any };
|
87 |
|
88 | type PrevCaller<T extends string, R = T> = (
|
89 | prev: any,
|
90 | values: Answers<T>,
|
91 | prompt: PromptObject
|
92 | ) => R;
|
93 |
|
94 | type Falsy = false | null | undefined;
|
95 |
|
96 | type PromptType = "text" | "password" | "invisible" | "number" | "confirm" | "list" | "toggle" | "select" | "multiselect" | "autocomplete" | "date";
|
97 |
|
98 | type ValueOrFunc<T extends string> = T | PrevCaller<T>;
|
99 | }
|