import type { SlotRegistry } from '@teambit/harmony'; import type { CLIArgs, Flags, Command } from './command'; import type { GroupsType } from './command-groups'; import type { Logger, LoggerMain } from '@teambit/logger'; export type CommandList = Array; export type OnStart = (hasWorkspace: boolean, currentCommand: string, commandObject?: Command) => Promise; export type OnCommandStart = (commandName: string, args: CLIArgs, flags: Flags) => Promise; export type OnBeforeExitFn = () => Promise; export type OnStartSlot = SlotRegistry; export type OnCommandStartSlot = SlotRegistry; export type CommandsSlot = SlotRegistry; export type OnBeforeExitSlot = SlotRegistry; export declare class CLIMain { private commandsSlot; private onStartSlot; readonly onCommandStartSlot: OnCommandStartSlot; private onBeforeExitSlot; private logger; groups: GroupsType; constructor(commandsSlot: CommandsSlot, onStartSlot: OnStartSlot, onCommandStartSlot: OnCommandStartSlot, onBeforeExitSlot: OnBeforeExitSlot, logger: Logger); /** * registers a new command in to the CLI. */ register(...commands: CommandList): void; /** * helpful for having the same command name in different environments (e.g. legacy and non-legacy). * for example `cli.unregister('tag');` removes the "bit tag" command. */ unregister(commandName: string): void; /** * list of all registered commands. (legacy and new). */ get commands(): CommandList; /** * get an instance of a registered command. (useful for aspects to modify and extend existing commands) */ getCommand(name: string): Command | undefined; getCommandByNameOrAlias(name: string): Command | undefined; /** * when running `bit help`, commands are grouped by categories. * this method helps registering a new group by providing its name and a description. * the name is what needs to be assigned to the `group` property of the Command interface. * the description is what shown in the `bit help` output. */ registerGroup(name: string, description: string): void; /** * onStart is when bootstrapping the CLI. (it happens before onCommandStart) */ registerOnStart(onStartFn: OnStart): this; /** * onCommandStart is when a command is about to start and we have the command object and the parsed args and flags * already. (it happens after onStart) */ registerOnCommandStart(onCommandStartFn: OnCommandStart): this; /** * This will register a function to be called before the process exits. * This will run only for "regular" exits * e.g. * yes - command run and finished successfully * yes - command run and failed gracefully (code 1) * not SIGKILL (kill -9) * not SIGINT (Ctrl+C) * not SIGTERM (kill) * not uncaughtException * not unhandledRejection * * @param onBeforeExitFn * @returns */ registerOnBeforeExit(onBeforeExitFn: OnBeforeExitFn): this; /** * execute commands registered to this aspect. */ run(hasWorkspace: boolean): Promise; private invokeOnStart; private setDefaults; static dependencies: import("@teambit/harmony").Aspect[]; static runtime: import("@teambit/harmony").RuntimeDefinition; static slots: (((registerFn: () => string) => SlotRegistry) | ((registerFn: () => string) => SlotRegistry) | ((registerFn: () => string) => SlotRegistry))[]; static provider([loggerMain]: [LoggerMain], config: any, [commandsSlot, onStartSlot, onCommandStartSlot, onBeforeExitSlot]: [ CommandsSlot, OnStartSlot, OnCommandStartSlot, OnBeforeExitSlot ]): Promise; }