UNPKG

@elsikora/commitizen-plugin-commitlint-ai

Version:
118 lines (117 loc) 5.78 kB
import type { ICliInterfaceServiceSelectOptions } from '../../application/interface/cli-interface-service-select-options.interface'; import type { ICliInterfaceService } from '../../application/interface/cli-interface-service.interface'; /** * Implementation of the CLI interface service using the prompts library. * Provides methods for interacting with the user through the command line. */ export declare class PromptsCliInterface implements ICliInterfaceService { /** Reference to the active spinner instance */ private spinner; /** * Initializes a new instance of the PromptsCliInterface. * Sets up the spinner for providing visual feedback during operations. */ constructor(); /** * Clears the console screen. */ clear(): void; /** * Displays a confirmation prompt to the user. * @param {string} message - The message to display to the user * @param {boolean} isConfirmedByDefault - The default value for the confirmation, defaults to false * @returns {Promise<boolean>} Promise that resolves to the user's response (true for confirmed, false for declined) */ confirm(message: string, isConfirmedByDefault?: boolean): Promise<boolean>; /** * Displays an error message to the user. * @param {string} message - The error message to display */ error(message: string): void; /** * Displays a grouped multi-select prompt to the user. * @param {string} message - The message to display to the user * @param {Record<string, Array<ICliInterfaceServiceSelectOptions>>} options - Record of groups and their options * @param {boolean} isRequired - Whether a selection is required, defaults to false * @param {Array<string>} initialValues - Initial selected values * @returns {Promise<Array<T>>} Promise that resolves to an array of selected values * @template T - The type of the selected values */ groupMultiselect<T>(message: string, options: Record<string, Array<ICliInterfaceServiceSelectOptions>>, isRequired?: boolean, initialValues?: Array<string>): Promise<Array<T>>; /** * Handles and displays an error message with additional error details. * @param {string} message - The error message to display * @param {unknown} error - The error object or details */ handleError(message: string, error: unknown): void; /** * Displays an informational message to the user. * @param {string} message - The info message to display */ info(message: string): void; /** * Displays a standard message to the user. * @param {string} message - The message to display */ log(message: string): void; /** * Displays a multi-select prompt to the user. * @param {string} message - The message to display to the user * @param {Array<ICliInterfaceServiceSelectOptions>} options - Array of options to select from * @param {boolean} isRequired - Whether a selection is required, defaults to false * @param {Array<string>} initialValues - Initial selected values * @returns {Promise<Array<T>>} Promise that resolves to an array of selected values * @template T - The type of the selected values */ multiselect<T>(message: string, options: Array<ICliInterfaceServiceSelectOptions>, isRequired?: boolean, initialValues?: Array<string>): Promise<Array<T>>; /** * Displays a note to the user with a title and message. * @param {string} title - The title of the note * @param {string} message - The message content of the note */ note(title: string, message: string): void; /** * Displays a single select prompt to the user. * @param {string} message - The message to display to the user * @param {Array<ICliInterfaceServiceSelectOptions>} options - Array of options to select from * @param {string} initialValue - Initial selected value * @returns {Promise<T>} Promise that resolves to the selected value * @template T - The type of the selected value */ select<T>(message: string, options: Array<ICliInterfaceServiceSelectOptions>, initialValue?: string): Promise<T>; /** * Starts a spinner with the specified message. * Stops any existing spinner first. * @param {string} message - The message to display while the spinner is active */ startSpinner(message: string): void; /** * Stops the current spinner with an optional completion message. * @param {string} message - Optional message to display when the spinner stops */ stopSpinner(message?: string): void; /** * Displays a success message to the user. * @param {string} message - The success message to display */ success(message: string): void; /** * Displays a text input prompt to the user. * @param {string} message - The message to display to the user * @param {string} _placeholder - Optional placeholder text for the input field (unused) * @param {string} initialValue - Optional initial value for the input field * @param {(value: string) => Error | string | undefined} validate - Optional validation function for the input * @returns {Promise<string>} Promise that resolves to the user's input text */ text(message: string, _placeholder?: string, initialValue?: string, validate?: (value: string) => Error | string | undefined): Promise<string>; /** * Update the spinner message without stopping it. * @param {string} message - The new message to display */ updateSpinner(message: string): void; /** * Displays a warning message to the user. * @param {string} message - The warning message to display */ warn(message: string): void; }