UNPKG

promptify.ts

Version:

A easy and modern npm package that controls users inputs to prompt the user in cmd.

190 lines (180 loc) 5.66 kB
declare enum Design { Simple = 0, Modern = 1, Colorful = 2 } type Format = "json" | "text"; type Selection = "multiple" | "single"; type FileType = "file" | "folder"; type Prompt = "text" | "number" | "word"; type UrlProtocol = "http" | "https" | "http(s)"; interface InputJsonOutput { answer: string; index?: number; choices?: number; } interface InputBoolSettings { q: string; required?: boolean; default_bool?: boolean; format?: Format; design?: InputBoolDesignSettings; } interface InputBoolDesignSettings { header: Design; body: Design; colors: InputBoolDesignColorSettings; } interface InputBoolDesignColorSettings { box_color: string; shadow_color: string; } interface InputPwdSettings { q: string; required?: boolean; format?: Format; design?: InputPwdDesignSettings; } interface InputPwdDesignSettings { header: Design; body: Design; colors: InputPwdDesignColorSettings; } interface InputPwdDesignColorSettings { box_color: string; shadow_color: string; } interface InputPromptSettings { type: Prompt; q: string; required?: boolean; format?: Format; design?: InputPromptDesignSettings; } interface InputPromptDesignSettings { header: Design; body: Design; colors: InputPromptDesignColorSettings; } interface InputPromptDesignColorSettings { box_color: string; shadow_color: string; } interface InputSelectionSettings { type: Selection; choices: string[]; q: string; format?: Format; design?: InputSelectionDesignSettings; } interface InputSelectionDesignSettings { header: Design; body: Design; colors: InputSelectionDesignColorSettings; } interface InputSelectionDesignColorSettings { box_color: string; shadow_color: string; } interface InputFiledialogSettings { type: FileType; q: string; startPath?: string; extensions?: string; showHiddenFolders?: boolean; format?: Format; design?: InputFiledialogDesignSettings; } interface InputFiledialogDesignSettings { header: Design; body: Design; colors: InputFiledialogDesignColorSettings; } interface InputFiledialogDesignColorSettings { box_color: string; shadow_color: string; } interface InputDateSettings { q: string; startDate?: Date; format?: Format; design?: InputDateDesignSettings; } interface InputDateDesignSettings { header: Design; body: Design; colors: InputDateDesignColorSettings; } interface InputDateDesignColorSettings { box_color: string; shadow_color: string; } interface InputUrlSettings { q: string; protocol?: UrlProtocol; required?: boolean; format?: Format; design?: InputUrlDesignSettings; } interface InputUrlDesignSettings { header: Design; body: Design; colors: InputUrlDesignColorSettings; } interface InputUrlDesignColorSettings { box_color: string; shadow_color: string; } declare class Input { VERSION: string; AUTHOR: string; ID: string; private logger; constructor(); bool({ q, required, default_bool, format, design, }: InputBoolSettings): Promise<string | InputJsonOutput | null>; pwd({ q, required, format, design, }: InputPwdSettings): Promise<string | InputJsonOutput | null>; date({ q, startDate, format, design, }: InputDateSettings): Promise<string | InputJsonOutput | null>; prompt({ type, q, required, format, design, }: InputPromptSettings): Promise<string | InputJsonOutput | null>; selection({ type, choices, q, format, design, }: InputSelectionSettings): Promise<unknown>; filedialog({ type, q, startPath, extensions, showHiddenFolders, format, design, }: InputFiledialogSettings): Promise<unknown>; url({ protocol, q, required, format, design, }: InputUrlSettings): Promise<string | InputJsonOutput | null>; } declare const Colors: { reset: string; foreground: { black: string; cyan: string; yellow: string; green: string; gray: string; white: string; red: string; }; background: { gray: string; white: string; }; }; declare class Logger { private colors; constructor(); print(message: string, updateable?: boolean): void; test(): void; } declare class Filesystem { private extensions; private showHiddenFolders; private showFiles; constructor(extensions: string, showHiddenFolders?: boolean, showFiles?: boolean); getPath(location: string): string; getFile(location: string, name: string): string; getContentByLocation(location: string): Promise<Item[]>; back(location: string): string; go(location: string, item: string): string; } type Type = "folder" | "file"; interface Item { type: Type; name: string; } export { Colors, Design, type FileType, Filesystem, type Format, Input, type InputBoolDesignColorSettings, type InputBoolDesignSettings, type InputBoolSettings, type InputDateDesignColorSettings, type InputDateDesignSettings, type InputDateSettings, type InputFiledialogDesignColorSettings, type InputFiledialogDesignSettings, type InputFiledialogSettings, type InputJsonOutput, type InputPromptDesignColorSettings, type InputPromptDesignSettings, type InputPromptSettings, type InputPwdDesignColorSettings, type InputPwdDesignSettings, type InputPwdSettings, type InputSelectionDesignColorSettings, type InputSelectionDesignSettings, type InputSelectionSettings, type InputUrlDesignColorSettings, type InputUrlDesignSettings, type InputUrlSettings, type Item, Logger, type Prompt, type Selection, type Type, type UrlProtocol };