import { defineWithTypes } from 'gunshi' import { dryRunId, type DryRunExtensions } from './shared.ts' export const command = defineWithTypes<{ extensions: DryRunExtensions }>()({ name: 'init', description: 'Set up a config, install plugins, and run the first generation.', examples: [ 'kubb init', 'kubb init --yes', 'kubb init --input ./openapi.yaml --output ./src/gen --plugins plugin-ts,plugin-zod', 'kubb init --yes --input ./openapi.yaml --plugins ts,zod --output src/api', 'kubb init --plugins plugin-ts,plugin-axios,plugin-react-query', 'kubb init --yes --dry-run', ].join('\n'), toKebab: true, args: { yes: { type: 'boolean', description: 'Skip prompts and use the detected spec, the default plugin, and the default output folder', short: 'y', default: false, }, input: { type: 'string', description: 'Path to the OpenAPI specification', short: 'i', metavar: 'path', }, output: { type: 'string', description: 'Output directory for generated files', short: 'o', metavar: 'path', }, plugins: { type: 'string', description: 'Comma-separated Kubb registry ids of the plugins to add, the same ids `kubb add` takes (plugin-ts, plugin-zod, acme/plugin-x), or short names (ts, zod)', metavar: 'plugin-ts,plugin-zod,...', }, }, async run({ values, extensions }) { // Imported here, so `kubb --help` does not load the runner. const { run } = await import('../runners/init/run.ts') await run({ yes: values.yes, input: values.input, output: values.output, plugins: values.plugins, dryRun: extensions[dryRunId] }) }, })