Skip to content

Function: defineCliSubcommand()

Makaio Framework


Makaio Framework / kernel/cli / defineCliSubcommand

defineCliSubcommand<T>(name, description, schema, handler): CliSubcommandEntry

Defined in: ../../../packages/kernel/src/cli/types.ts:197

Define a CLI subcommand with full type inference from schema to handler.

This is an identity function whose only purpose is to create a scope where TypeScript infers T from schema and flows it into handler. No runtime cost. Same pattern as Vite’s defineConfig() or Vue’s defineComponent().

T extends ZodObject<Readonly<{[k: string]: $ZodType<unknown, unknown, $ZodTypeInternals<unknown, unknown>>; }>, $strip>

string

Subcommand name.

string

One-line description for help text.

T

Zod object schema defining options/arguments.

(ctx) => Promise<void>

Async handler receiving the typed CommandContext.

CliSubcommandEntry

A CliSubcommandEntry suitable for inclusion in a CliContribution.