Skip to main content

collectServiceCommands

@webda/core


Function: collectServiceCommands()

collectServiceCommands(app): object

Defined in: packages/core/src/services/servicecommands.ts:67

Collect all CLI commands declared by services across all loaded modules.

Scans the moddas, beans, and deployers sections of webda.module.json for services that have commands metadata (generated by the @Command decorator at compile time). Merges commands from multiple services that declare the same command name — each service becomes an entry in the services array, and args are merged (first definition wins for each arg name).

Parameters​

app​

Application

The loaded Webda Application with module metadata available

Returns​

object

A map of command names to their merged definitions

Example​

const commands = collectServiceCommands(app);
// {
// "serve": {
// description: "Start the HTTP server",
// services: [{ name: "Webda/HttpServer", method: "serve", type: "Webda/HttpServer" }],
// args: { port: { type: "number", default: 18080, alias: "p" } }
// }
// }