LogoRobo.js
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 ParameterDefault type
C extends CliCommandConfig | undefinedundefined

Properties

PropertyTypeDescription
argsstring[]Parsed positional arguments
argvstring[]Raw argv after command name
cwdstringProject working directory
loggerLoggerLogger instance (forked for plugins)
optionsC extends CliCommandConfig ? CliOptionsFromConfig<C<C>> : Record<string, unknown>Parsed options (flag values) - typed when using createCliCommandConfig
result?unknownResult data from command handler (available to after hooks)

On this page