UNPKG

zod-opts

Version:

node.js CLI option parser / validator using Zod

30 lines 827 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const zod_1 = require("zod"); // import { parser } from "zod-opts"; const index_1 = require("../src/index"); const OptionsSchema = zod_1.z.object({ opt1: zod_1.z.string(), opt2: zod_1.z.number().optional(), pos1: zod_1.z.enum(["a", "b"]), }); function parseOptions() { return (0, index_1.parser)() .name("scriptA") .version("1.0.0") .description("desc") .options({ opt1: { type: OptionsSchema.shape.opt1 }, opt2: { type: OptionsSchema.shape.opt2 }, }) .args([ { name: "pos1", type: OptionsSchema.shape.pos1, }, ]) .parse(); } const options = parseOptions(); console.log(options); //# sourceMappingURL=map_zod_object.js.map