Framework
CliContext<C>
Interface: CliContext<C>
Context passed to CLI command handlers. Pass your config type as the generic parameter to get typed options.
Example
import { createCliCommandConfig, type CliContext } from 'robo.js/cli.js'
export const config = createCliCommandConfig({
description: 'My command',
options: [
{ alias: '-n', name: '--name', type: 'string', required: true }
]
} as const)
export default function myCommand(ctx: CliContext<typeof config>) {
ctx.options.name // TypeScript knows this is `string`
}Type Parameters
| Type Parameter | Default type |
|---|---|
C extends CliCommandConfig | undefined | undefined |
Properties
| Property | Type | Description |
|---|---|---|
args | string[] | Parsed positional arguments |
argv | string[] | Raw argv after command name |
cwd | string | Project working directory |
logger | Logger | Logger instance (forked for plugins) |
options | C extends CliCommandConfig ? CliOptionsFromConfig<C<C>> : Record<string, unknown> | Parsed options (flag values) - typed when using createCliCommandConfig |
result? | unknown | Result data from command handler (available to after hooks) |
