collectServiceCommands
Function: collectServiceCommands()
collectServiceCommands(
app,cli?,operationIds?):object
Defined in: packages/core/src/services/servicecommands.ts:218
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).
The application webda.cli configuration (package.json) selects the commands first:
include keeps only the listed commands (with their subcommands), then exclude
removes a provider ("Webda/HttpServer:serve") or a whole command ("openapi", with
its subcommands). The selection applies to the operation commands too, see selectOperations:
an entry matching neither a command nor an operation is logged as a warning. Two remaining
providers declaring the same argument with another type or at another position are
logged as a warning too: every handler receives the same positional values.
Parameters
app
The loaded Webda Application with module metadata available
cli?
Pick<WebdaCliDescriptor, "include" | "exclude"> = ...
The command selection, read from the application package.json by default
operationIds?
string[] = []
The operation ids of the application (.webda/operations.json): an entry selecting
only operations is not reported as matching nothing
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" } }
// }
// }