1 import { EventEmitter } from "events";
3 interface BasePromptOptions {
4 name: string | (() => string)
5 type: string | (() => string)
6 message: string | (() => string) | (() => Promise<string>)
9 format?(value: string): string | Promise<string>
10 result?(value: string): string | Promise<string>
11 skip?: ((state: object) => boolean | Promise<boolean>) | boolean
12 validate?(value: string): boolean | Promise<boolean> | string | Promise<string>
13 onSubmit?(name: string, value: any, prompt: Enquirer.Prompt): boolean | Promise<boolean>
14 onCancel?(name: string, value: any, prompt: Enquirer.Prompt): boolean | Promise<boolean>
15 stdin?: NodeJS.ReadStream
16 stdout?: NodeJS.WriteStream
24 disabled?: boolean | string
27 interface ArrayPromptOptions extends BasePromptOptions {
37 choices: string[] | Choice[]
46 align?: 'left' | 'right'
50 interface BooleanPromptOptions extends BasePromptOptions {
55 interface StringPromptOptions extends BasePromptOptions {
56 type: 'input' | 'invisible' | 'list' | 'password' | 'text'
61 interface NumberPromptOptions extends BasePromptOptions {
73 interface SnippetPromptOptions extends BasePromptOptions {
79 interface SortPromptOptions extends BasePromptOptions {
89 | BooleanPromptOptions
92 | SnippetPromptOptions
95 declare class BasePrompt extends EventEmitter {
96 constructor(options?: PromptOptions);
103 declare class Enquirer<T = object> extends EventEmitter {
104 constructor(options?: object, answers?: T);
107 * Register a custom prompt type.
110 * @param fn `Prompt` class, or a function that returns a `Prompt` class.
112 register(type: string, fn: typeof BasePrompt | (() => typeof BasePrompt)): this;
115 * Register a custom prompt type.
117 register(type: { [key: string]: typeof BasePrompt | (() => typeof BasePrompt) }): this;
120 * Prompt function that takes a "question" object or array of question objects,
121 * and returns an object with responses from the user.
123 * @param questions Options objects for one or more prompts to run.
128 | ((this: Enquirer) => PromptOptions)
129 | (PromptOptions | ((this: Enquirer) => PromptOptions))[]
133 * Use an enquirer plugin.
135 * @param plugin Plugin function that takes an instance of Enquirer.
137 use(plugin: (this: this, enquirer: this) => void): this;
140 declare namespace Enquirer {
141 function prompt<T = object>(
144 | ((this: Enquirer) => PromptOptions)
145 | (PromptOptions | ((this: Enquirer) => PromptOptions))[]
148 class Prompt extends BasePrompt {}