From 61fced1008b8bb39b3104d0d69381b11367be1fa Mon Sep 17 00:00:00 2001 From: Killer Boss Original <73131550+killerbossoriginal@users.noreply.github.com> Date: Thu, 26 Jan 2023 19:51:41 +0000 Subject: [PATCH] 2022.01.26 --- index.d.ts | 88 ++++++++++++++++++++++++++++++++++++++++++++++++++++ package.json | 2 +- tslint.json | 1 + 3 files changed, 90 insertions(+), 1 deletion(-) create mode 100644 index.d.ts create mode 100644 tslint.json diff --git a/index.d.ts b/index.d.ts new file mode 100644 index 0000000..60c570f --- /dev/null +++ b/index.d.ts @@ -0,0 +1,88 @@ +// Type definitions for readline-sync 1.4 +// Project: https://github.com/anseki/readline-sync +// Definitions by: Tristan Jones +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export type OptionType = string | number | RegExp | ((input: string) => boolean); + +export interface BasicOptions { + prompt?: any; + hideEchoBack?: boolean | undefined; + mask?: string | undefined; + limit?: OptionType | OptionType[] | undefined; + limitMessage?: string | undefined; + defaultInput?: string | undefined; + trueValue?: OptionType | OptionType[] | undefined; + falseValue?: OptionType | OptionType[] | undefined; + caseSensitive?: boolean | undefined; + keepWhitespace?: boolean | undefined; + encoding?: string | undefined; + bufferSize?: number | undefined; + print?(display: string, encoding: string): void; + history?: boolean | undefined; + cd?: boolean | undefined; + charlist?: string | undefined; + min?: any; + max?: any; + confirmMessage?: any; + unmatchMessage?: any; + exists?: any; + isFile?: boolean | undefined; + isDirectory?: boolean | undefined; + validate?(path: string): boolean | string; + create?: boolean | undefined; + guide?: boolean | undefined; + cancel?: any; +} + +// Basic Functions +export function question(query?: any, options?: BasicOptions): string; +export function prompt(options?: BasicOptions): string; +export function keyIn(query?: any, options?: BasicOptions): string; +export function setDefaultOptions(options?: BasicOptions): BasicOptions; + +// Utility Functions +export function questionEMail(query?: any, options?: BasicOptions): string; +export function questionNewPassword(query?: any, options?: BasicOptions): string; +export function questionInt(query?: any, options?: BasicOptions): number; +export function questionFloat(query?: any, options?: BasicOptions): number; +export function questionPath(query?: any, options?: BasicOptions): string; + +export function promptCL(commandHandler?: { [id: string]: (...args: string[]) => void } | ((command: string, ...args: string[]) => void), options?: BasicOptions): string[]; +export function promptLoop(inputHandler: (value: string) => boolean, options?: BasicOptions): void; +export function promptCLLoop(commandHandler?: { [id: string]: (...args: string[]) => boolean | void } | ((command: string, ...args: string[]) => boolean | void), options?: BasicOptions): void; +export function promptSimShell(options?: BasicOptions): string; + +export function keyInYN(query?: any, options?: BasicOptions): boolean | string; +export function keyInYNStrict(query?: any, options?: BasicOptions): boolean; +export function keyInPause(query?: any, options?: BasicOptions): void; +export function keyInSelect(items: string[], query?: any, options?: BasicOptions): number; + +export function getRawInput(): string; + +// Deprecated + +/** + * @deprecated Use the bufferSize option instead: readlineSync.setDefaultOptions({bufferSize: value}); + */ +export function setBufferSize(value: number): void; + +/** + * @deprecated Use the encoding option instead: readlineSync.setDefaultOptions({encoding: value}); + */ +export function setEncoding(value: string): void; + +/** + * @deprecated Use the mask option instead: readlineSync.setDefaultOptions({mask: value}); + */ +export function setMask(value: string): void; + +/** + * @deprecated Use the print option instead: readlineSync.setDefaultOptions({print: value}); + */ +export function setPrint(value: (display: string, encoding: string) => void): void; + +/** + * @deprecated Use the prompt option instead: readlineSync.setDefaultOptions({prompt: value}); + */ +export function setPrompt(value: any): void; \ No newline at end of file diff --git a/package.json b/package.json index 476f8c2..ff7d73f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@thundernetworkrad/readline-sync", - "version": "2023.01.10", + "version": "2023.01.26", "title": "readlineSync", "description": "Synchronous Readline for interactively running to have a conversation with the user via a console(TTY).", "keywords": [ diff --git a/tslint.json b/tslint.json new file mode 100644 index 0000000..89bfe2f --- /dev/null +++ b/tslint.json @@ -0,0 +1 @@ +{ "extends": "@definitelytyped/dtslint/dt.json" } \ No newline at end of file