zod-opts
Version:
node.js CLI option parser / validator using Zod
30 lines • 905 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const zod_1 = require("zod");
// import { parser } from "zod-opts";
const index_1 = require("../src/index");
const parsed = (0, index_1.parser)()
.options({
option1: {
type: zod_1.z.boolean(), // required option. type is boolean
},
option2: {
type: zod_1.z.boolean().default(false), // optional option. type is boolean
},
option3: {
type: zod_1.z.boolean().optional(), // optional option. type is boolean|undefined
},
option4: {
type: zod_1.z.boolean().default(false).optional(), // optional option. type is boolean|undefined
},
})
.parse();
// parsed is inferred as below:
// const parsed: {
// option1: boolean;
// option2: boolean;
// option3?: boolean;
// option4?: boolean;
// }
console.log(parsed);
//# sourceMappingURL=boolean.js.map