UNPKG

oazapfts

Version:

OpenApi TypeScript client generator

76 lines (74 loc) 2.27 kB
#!/usr/bin/env node import "./context-BZ7CId2F.js"; import { h as e, t } from "./generateClientMethod-CQwJveeR.js"; import { n } from "./src-CbQmhGca.js"; import { readFile as r, writeFile as i } from "fs/promises"; import a from "minimist"; import { join as o } from "path"; //#region src/cli.ts async function s(a) { let { include: s, exclude: l, optimistic: u, useEnumType: d, enumStyle: f, mergeReadWriteOnly: p, useUnknown: m, argumentStyle: h, allSchemas: g, numericBooleanQueryParameters: _, futureStripLegacyMethods: v, help: y, version: b } = a, [x, S] = a._; if (y && (c(), process.exit(0)), b) { let e = JSON.parse(await r(o(__dirname, "..", "package.json"), "utf8")); console.log(e.version), process.exit(0); } x || (c(), process.exit(1)), h !== void 0 && !t.includes(h) && (console.error(`--argumentStyle should be one of <${t.join(" | ")}>, but got "${h}"`), process.exit(1)), f !== void 0 && !e.includes(f) && (console.error(`--enumStyle should be one of <${e.join(" | ")}>, but got "${f}"`), process.exit(1)); let C = await n(x, { include: s, exclude: l, optimistic: u, useEnumType: d, enumStyle: f, useUnknown: m, mergeReadWriteOnly: p, argumentStyle: h, allSchemas: g, numericBooleanQueryParameters: _, futureStripLegacyMethods: v }); S ? await i(S, C) : console.log(C); } function c() { console.error(` Usage: oazapfts <spec> [filename] Options: --exclude, -e <tag to exclude> --include, -i <tag to include> --help, -h --version, -v --optimistic --useEnumType (deprecated, use --enumStyle=enum) --enumStyle=<${e.join(" | ")}> (default: union) --useUnknown --mergeReadWriteOnly --argumentStyle=<${t.join(" | ")}> (default: positional) --allSchemas --numericBooleanQueryParameters --futureStripLegacyMethods `); } s(a(process.argv.slice(2), { alias: { h: "help", v: "version", i: "include", e: "exclude" }, boolean: [ "help", "version", "optimistic", "useEnumType", "mergeReadWriteOnly", "useUnknown", "allSchemas", "numericBooleanQueryParameters", "futureStripLegacyMethods" ], string: ["argumentStyle", "enumStyle"] })).catch((e) => { console.error(e), process.exit(1); }); //#endregion //# sourceMappingURL=cli.js.map