1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 | import { EventEmitter } from 'events';
|
9 | import { ReadStream, WriteStream } from 'tty';
|
10 | import 'revalidator';
|
11 |
|
12 | declare namespace prompt {
|
13 | type GetCallback<T> = (err: Error | null, result: T) => void;
|
14 | type AddCallback = (err: Error | null) => void;
|
15 | type AskFunction = () => boolean;
|
16 | type BeforeFunction = (line: string) => string;
|
17 |
|
18 | type RevalidatorSchema = Partial<Revalidator.ISchema<any>> & {
|
19 | ask?: AskFunction | undefined;
|
20 | before?: BeforeFunction | undefined;
|
21 | name?: string | undefined;
|
22 | raw?: [string, string] | undefined;
|
23 | hidden?: boolean;
|
24 | };
|
25 |
|
26 | interface Properties {
|
27 | [name: string]: RevalidatorSchema | string;
|
28 | }
|
29 |
|
30 | interface Schema {
|
31 | properties: Properties;
|
32 | }
|
33 |
|
34 | interface History {
|
35 | property: RevalidatorSchema | string;
|
36 | value: string;
|
37 | }
|
38 |
|
39 | interface StartOptions {
|
40 | allowEmpty?: boolean | undefined;
|
41 | colors?: boolean | undefined;
|
42 | delimiter?: string | undefined;
|
43 | memory?: number | undefined;
|
44 | message?: string | undefined;
|
45 | noHandleSIGINT?: boolean | undefined;
|
46 | stdin?: ReadStream | undefined;
|
47 | stdout?: WriteStream | undefined;
|
48 | }
|
49 | }
|
50 |
|
51 | declare class prompt extends EventEmitter {
|
52 | on(event: 'invalid', listener: (prop: prompt.RevalidatorSchema | string, line: number) => void): this;
|
53 | on(event: 'prompt', listener: (prop: prompt.RevalidatorSchema | string) => void): this;
|
54 | on(event: 'pause' | 'resume' | 'SIGINT' | 'start' | 'stop', listener: () => void): this;
|
55 |
|
56 | static colors: boolean;
|
57 | static delimiter: string;
|
58 | static message: string;
|
59 | static override?: any;
|
60 | static version: string;
|
61 |
|
62 | static addProperties(obj: any, values: Array<string | prompt.RevalidatorSchema>): Promise<void>;
|
63 | static addProperties(
|
64 | obj: any,
|
65 | values: Array<string | prompt.RevalidatorSchema>,
|
66 | callback: prompt.GetCallback<prompt.Properties>,
|
67 | ): void;
|
68 | static get<T extends prompt.Properties>(
|
69 | values: Array<keyof T | prompt.Schema | prompt.RevalidatorSchema> | prompt.Schema | prompt.RevalidatorSchema,
|
70 | ): Promise<T>;
|
71 | static get<T extends prompt.Properties>(
|
72 | values: Array<keyof T | prompt.Schema | prompt.RevalidatorSchema> | prompt.Schema | prompt.RevalidatorSchema,
|
73 | callback: prompt.GetCallback<T>,
|
74 | ): void;
|
75 | static history(name?: string | number): prompt.History | null;
|
76 | static start(options?: prompt.StartOptions): void;
|
77 | }
|
78 |
|
79 | export = prompt;
|