UNPKG

typed-openapi

Version:
33 lines (31 loc) 1.65 kB
import { generateClientFiles } from "./chunk-62WASHT2.js"; import { allowedRuntimes } from "./chunk-ZM3UP6UJ.js"; import "./chunk-KAEXXJ7X.js"; // src/cli.ts import { cac } from "cac"; import { readFileSync } from "fs"; var { name, version } = JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf8")); var cli = cac(name); cli.command("<input>", "Generate").option("-o, --output <path>", "Output path for the api client ts file (defaults to `<input>.<runtime>.ts`)").option( "-r, --runtime <n>", `Runtime to use for validation; defaults to \`none\`; available: ${allowedRuntimes.toString()}`, { default: "none" } ).option("--schemas-only", "Only generate schemas, skipping client generation (defaults to false)", { default: false }).option("--include-client", "Include API client types and implementation (defaults to true)", { default: true }).option( "--success-status-codes <codes>", "Comma-separated list of success status codes (defaults to 2xx and 3xx ranges)" ).option("--error-status-codes <codes>", "Comma-separated list of error status codes (defaults to 4xx and 5xx ranges)").option( "--tanstack [name]", "Generate tanstack client, defaults to false, can optionally specify a name (will be generated next to the main file) or absolute path for the generated file" ).option( "--default-fetcher [name]", "Generate default fetcher, defaults to false, can optionally specify a name (will be generated next to the main file) or absolute path for the generated file" ).action(async (input, _options) => { return generateClientFiles(input, _options); }); cli.help(); cli.version(version); cli.parse();