///
export = prompts;
import { Kleur } from "kleur";
import { Readable, Writable } from "stream";
declare function prompts(
questions: prompts.PromptObject | Array>,
options?: prompts.Options,
): Promise>;
declare namespace prompts {
// Circular reference from prompts
const prompt: any;
function inject(arr: readonly any[]): void;
namespace inject {
const prototype: {};
}
function override(obj: { [key: string]: any }): void;
namespace override {
const prototype: {};
}
namespace prompts {
function autocomplete(args: PromptObject): any;
function confirm(args: PromptObject): void;
function date(args: PromptObject): any;
function invisible(args: PromptObject): any;
function list(args: PromptObject): any;
function multiselect(args: PromptObject): any;
function number(args: PromptObject): void;
function password(args: PromptObject): any;
function select(args: PromptObject): void;
function text(args: PromptObject): void;
function toggle(args: PromptObject): void;
}
// Based upon: https://github.com/terkelg/prompts/blob/d7d2c37a0009e3235b2e88a7d5cdbb114ac271b2/lib/elements/select.js#L29
interface Choice {
title: string;
value?: any;
disabled?: boolean | undefined;
selected?: boolean | undefined;
description?: string | undefined;
}
interface Options {
onSubmit?: ((prompt: PromptObject, answer: any, answers: any[]) => void) | undefined;
onCancel?: ((prompt: PromptObject, answers: any) => void) | undefined;
}
interface PromptObject {
type: PromptType | Falsy | PrevCaller;
name: ValueOrFunc;
message?: ValueOrFunc | undefined;
initial?: InitialReturnValue | PrevCaller> | undefined;
style?: string | PrevCaller | undefined;
format?: PrevCaller | undefined;
validate?: PrevCaller> | undefined;
onState?: PrevCaller | undefined;
onRender?: ((kleur: Kleur) => void) | undefined;
min?: number | PrevCaller | undefined;
max?: number | PrevCaller | undefined;
float?: boolean | PrevCaller | undefined;
round?: number | PrevCaller | undefined;
instructions?: string | boolean | undefined;
increment?: number | PrevCaller | undefined;
separator?: string | PrevCaller | undefined;
active?: string | PrevCaller | undefined;
inactive?: string | PrevCaller | undefined;
choices?: Choice[] | PrevCaller | undefined;
hint?: string | PrevCaller | undefined;
warn?: string | PrevCaller | undefined;
suggest?: ((input: any, choices: Choice[]) => Promise) | undefined;
limit?: number | PrevCaller | undefined;
mask?: string | PrevCaller | undefined;
stdout?: Writable | undefined;
stdin?: Readable | undefined;
}
type Answers = { [id in T]: any };
type PrevCaller = (
prev: any,
values: Answers,
prompt: PromptObject,
) => R;
type Falsy = false | null | undefined;
type PromptType =
| "text"
| "password"
| "invisible"
| "number"
| "confirm"
| "list"
| "toggle"
| "select"
| "multiselect"
| "autocomplete"
| "date"
| "autocompleteMultiselect";
type ValueOrFunc = T | PrevCaller;
type InitialReturnValue = string | number | boolean | Date;
}