UNPKG

@nu-art/commando

Version:

Shell command execution framework with interactive sessions, CLI parameter resolution, and plugin system for building and executing shell scripts programmatically

43 lines (42 loc) 1.82 kB
import { Constructor } from '@nu-art/ts-common'; import { CommandoInteractive } from '../interactive/CommandoInteractive.js'; import { BaseCommando } from './BaseCommando.js'; import { Commando_Basic } from '../plugins/basic.js'; import { MergeTypes } from './class-merger.js'; /** * Pool manager for Commando instances with lifecycle management. * * Tracks all allocated Commando instances and provides a way to kill * all of them at once. Useful for cleanup in long-running processes * or test teardown. * * **Behavior**: * - All allocated commandos are stored in an internal pool * - `allocateCommando()` always includes Commando_Basic plugin * - `killAll()` terminates all tracked commandos asynchronously * * **Use Case**: Managing multiple interactive commandos that need * to be cleaned up together (e.g., test suites, long-running scripts). */ export declare const CommandoPool: { /** * Allocates a new Commando instance and adds it to the pool. * * Creates a CommandoInteractive instance with the provided plugins * plus Commando_Basic (always included). The instance is tracked * in the pool for later cleanup. * * @template T - Array of plugin constructor types * @param uid - Unique identifier for this commando instance * @param plugins - Plugin classes to merge with the commando * @returns Merged commando instance with all plugins */ allocateCommando: <T extends Constructor<any>[]>(uid: string, ...plugins: T) => MergeTypes<[...T]> & CommandoInteractive & BaseCommando & Commando_Basic; /** * Kills all allocated commando instances. * * Calls `kill()` on all commandos in the pool asynchronously. * Useful for cleanup in test teardown or application shutdown. */ killAll: () => Promise<void>; };