executeServiceCommand
Function: executeServiceCommand()
executeServiceCommand(
cmdName,cmdInfo,args,services,serviceFilter?):Promise<number>
Defined in: packages/core/src/services/servicecommands.ts:131
Execute a CLI command by dispatching to all services that declared it.
Services are executed in the order they were initialized (which follows the
dependency graph). The serviceFilter filters to specific services by name
(supports suffix matching).
Each service's command handler is called with the parsed arguments as positional parameters.
Parameters
cmdName
string
The command name to execute (e.g., "serve", "migrate")
cmdInfo
The merged command definition from collectServiceCommands
args
Parsed argument values keyed by argument name
services
Map of service name to service instance (from Core.getServices())
serviceFilter?
string[]
Optional list of service names to filter to (supports suffix matching)
Returns
Promise<number>
0 on success, 1 if no services match the filter, a method is missing or no service instance ran
Example
// Execute "migrate" on all services:
await executeServiceCommand("migrate", cmdInfo, { dryRun: true }, core.getServices());
// Execute "migrate" on a specific service:
await executeServiceCommand("migrate", cmdInfo, { dryRun: true }, core.getServices(), ["PostgresMigrator"]);