{"id":21703595,"url":"https://github.com/codemonument/deno_cliffy_zod_option","last_synced_at":"2026-05-20T04:41:18.549Z","repository":{"id":230766924,"uuid":"780097571","full_name":"codemonument/deno_cliffy_zod_option","owner":"codemonument","description":"A custom type for the cliffy cli framework to allow validating options via custom zod schemas","archived":false,"fork":false,"pushed_at":"2024-10-22T10:13:11.000Z","size":20,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-25T15:41:25.674Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/codemonument.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-03-31T17:24:34.000Z","updated_at":"2024-10-22T10:12:59.000Z","dependencies_parsed_at":"2024-03-31T20:20:58.792Z","dependency_job_id":"dfe33320-0f95-4e2b-992b-e009d22badcf","html_url":"https://github.com/codemonument/deno_cliffy_zod_option","commit_stats":null,"previous_names":["codemonument/deno_cliffy_zod_option"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codemonument%2Fdeno_cliffy_zod_option","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codemonument%2Fdeno_cliffy_zod_option/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codemonument%2Fdeno_cliffy_zod_option/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codemonument%2Fdeno_cliffy_zod_option/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/codemonument","download_url":"https://codeload.github.com/codemonument/deno_cliffy_zod_option/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244656466,"owners_count":20488638,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-25T21:33:42.581Z","updated_at":"2026-05-20T04:41:18.504Z","avatar_url":"https://github.com/codemonument.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Cliffy Extension: zodType\n\nThis package provides a custom options type for the cliffy cli framework.\nThe new Option type zodType allows to validate a cli option input with zod.\n\n## Usage Examples\n\n```typescript\nconst command = new Command()\n\t.name('cliffy-zod-option-demo')\n\t//1. register the custom cliffy types with the zodType function\n\t.type('zodString', zodType(z.string()))\n\t.type('zodInt', zodType(z.coerce.number().int()))\n\t.type('zodBaseColor', zodType(z.enum(['red', 'green', 'blue'])))\n\t// 2. Use the custom types in the options\n\t.option('--zodString \u003cvalue1:zodString\u003e', 'A string validated by zod')\n\t.option('--zodInt \u003cvalue2:zodInt\u003e', 'An integer validated by zod')\n\t.option(\n\t\t'--zodBaseColor \u003cbaseColor:zodBaseColor\u003e',\n\t\t'A base color value validated by zod enum (red, green or blue)'\n\t)\n\t.option('--requiredZodInt \u003cvalue3:zodInt\u003e', 'A required integer validated by zod', {\n\t\trequired: true,\n\t})\n\t.allowEmpty()\n\t.action(options =\u003e {\n\t\tif (Object.keys(options).length === 0) {\n\t\t\tcommand.showHelp();\n\t\t\treturn;\n\t\t}\n\n\t\t// 3. Options are already validated by zod\n\t\tconsole.log('CLI called with options:', options);\n\n\t\t// Note: due to the type design of cliffy, the options always contain the 'undefined' type for each option key, parallel to the type returned by zod.\n\t\t// This can be fixed by a simple if (!options.option) check or by using the zod schema again which was used for the option in the first place.\n\t});\n\nawait command.parse(args);\n```\n\n## Release new version (for maintainers)\n\n1. Update the version in the `deno.json` file.\n2. Update the version in the `src/cli.ts` file.\n\n---\n\n# Changelog\n\n## 1.0.1 - 2024-10-22\n\n- publish to jsr with provenance and upgrade to jsr @cliffy/command@1.0.0-rc.7\n\n## 1.0.0 - 2023-03-31\n\n- intial release, see README.md for usage examples\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodemonument%2Fdeno_cliffy_zod_option","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcodemonument%2Fdeno_cliffy_zod_option","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodemonument%2Fdeno_cliffy_zod_option/lists"}