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