UNPKG

@megaorm/cli

Version:

This package allows you to communicate with MegaORM via commands directly from the command line interface (CLI).

50 lines (49 loc) 2.23 kB
import { MegaCommand } from './MegaCommand'; /** * Custom error class for errors related to the MegaExecutor. */ export declare class MegaExecutorError extends Error { } /** * MegaExecutor is a class responsible for registering and executing commands in MegaORM. * It allows commands to be registered with a specific name and executed based on the provided name. */ export declare class MegaExecutor { /** * List of registered commands with their names and associated MegaCommand classes. * * @private * @static */ private static commands; /** * Registers a command under a specific name. If the name is already registered or the command is invalid, an error is thrown. * * @param name The name of the command. * @param command The `MegaCommand` subclass. * @throws `MegaExecutorError` if the name is invalid, the command class is not a subclass of `MegaCommand`, or if the name already exists. */ static register(name: string, command: typeof MegaCommand): void; /** * Executes the command associated with the argument passed from the command line. * * @returns A promise that resolves when the command finishes execution, or rejects with an error. * @throws `MegaExecutorError`if the command name is undefined, the command is unknown, or the `exec` method is invalid. */ static execute(): Promise<void>; } /** * Registers a command under a specific name. If the name is already registered or the command is invalid, an error is thrown. * * @param name The name of the command. * @param command The `MegaCommand` subclass. * @throws `MegaExecutorError` if the name is invalid, the command class is not a subclass of `MegaCommand`, or if the name already exists. */ export declare const register: (name: string, command: typeof MegaCommand) => void; /** * Executes the command associated with the argument passed from the command line. * * @returns A promise that resolves when the command finishes execution, or rejects with an error. * @throws `MegaExecutorError`if the command name is undefined, the command is unknown, or the `exec` method is invalid. */ export declare const execute: () => Promise<void>;