UNPKG

zod-opts

Version:

node.js CLI option parser / validator using Zod

27 lines 787 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 command1 = (0, index_1.command)("command1") .options({ option1: { type: zod_1.z.boolean().default(false), }, }) .action((parsed) => { // parsed is inferred as { option1: boolean } console.log("command1", parsed); }); const command2 = (0, index_1.command)("command2") .options({ option1: { type: zod_1.z.string(), }, }) .action((parsed) => { // parsed is inferred as { option1: string } console.log("command2", parsed); }); (0, index_1.parser)().subcommand(command1).subcommand(command2).parse(); //# sourceMappingURL=command.js.map