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