UNPKG

@nu-art/commando

Version:
55 lines (54 loc) 2.31 kB
import { Constructor } from '@nu-art/ts-common'; import { CommandBuilder } from './CommandBuilder'; export declare class BaseCommando { protected readonly builder: CommandBuilder; protected _debug: boolean; /** * Creates a new instance of BaseCommando merged with the provided plugins. * @param {Constructor<any>[]} plugins - The plugins to merge with BaseCommando. * @returns The Super type merged of BaseCommando and all the plugins provided new instance of BaseCommando merged with the plugins. */ static _create<T extends Constructor<any>[]>(...plugins: T): import("./class-merger").MergeTypes<[typeof BaseCommando, ...T]> & BaseCommando; /** * Constructs a BaseCommando instance. */ constructor(); /** * Toggles or sets the debug mode. * @param {boolean} [debug] - If provided, sets the debug mode to this value. Otherwise, toggles the current debug mode. * @returns {boolean} - The current state of debug mode. */ debug(debug?: boolean): this; /** * Appends a command to the command list. * @param {string} command - The command to append. * @returns {this} - The BaseCommando instance for method chaining. */ append(command: string): this; /** * Increases the current indentation level by one. * @returns {this} - The BaseCommando instance for method chaining. */ indentIn(): this; /** * Decreases the current indentation level by one. * @returns {this} - The BaseCommando instance for method chaining. */ indentOut(): this; /** * Appends an empty line to the script for readability. * @returns {this} - The BaseCommando instance for method chaining. */ emptyLine(): this; /** * Executes the commands. Must be overridden in a subclass. * @throws {ImplementationMissingException} - Always throws this exception. */ execute(): Promise<void>; /** * Executes the commands with a callback. Must be overridden in a subclass. * @param {Function} callback - A callback function to handle the command output. * @throws {ImplementationMissingException} - Always throws this exception. */ execute<T>(callback: (stdout: string, stderr: string, exitCode: number) => T): Promise<T>; }