Skip to main content

CommandDefinition

@webda/compiler


Type Alias: CommandDefinition

CommandDefinition = object

Defined in: definition.ts:354

Definition of a CLI command declared via the @Command decorator on a service method.

Written into webda.module.json under moddas[serviceName].commands or beans[serviceName].commands by the CommandsMetadata compiler plugin.

Example​

{
"description": "Start the HTTP server",
"method": "serve",
"args": {
"bind": { "type": "string", "default": "127.0.0.1", "alias": "b" },
"port": { "type": "number", "default": 18080, "alias": "p" }
}
}

Properties​

args​

args: object

Defined in: definition.ts:369

Map of argument name to its definition. Keys are method parameter names, which become --flag names in the CLI.

Index Signature​

[name: string]: CommandArgDefinition


description​

description: string

Defined in: definition.ts:359

Human-readable description of the command, displayed in CLI help output. Extracted from the description option in @Command("name", { description: "..." }).


method​

method: string

Defined in: definition.ts:364

Name of the method on the service class that handles this command. The shell calls service[method](...args) when the command is invoked.


phase?​

optional phase?: "resolved" | "initialized"

Defined in: definition.ts:382

Lifecycle phase at which this command runs.

  • "initialized" (default when omitted): after Core.init().
  • "resolved": after Core.resolve() only. No service.init() called. Used for build-time hooks (e.g. @BuildCommand).

requires?​

optional requires?: string[]

Defined in: definition.ts:375

Capabilities required by this command. The CLI resolves these against the capabilities map and auto-injects missing services before booting Core.