-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathprompt.ts
More file actions
24 lines (22 loc) · 878 Bytes
/
prompt.ts
File metadata and controls
24 lines (22 loc) · 878 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import { z } from 'zod/v4'
import { Command } from '../src/_entrypoints/_.js'
import { Zod } from '../src/_entrypoints/extensions.js'
const args = await Command.create()
.use(Zod)
// required
.parameter(`alpha`, z.string())
.parameter(`bravo`, z.number())
.parameter(`charlie`, z.boolean())
.parameter(`delta`, z.enum([`echo`, `foxtrot`, `golf`]))
.parameter(`hotel`, z.union([z.string(), z.number(), z.enum([`a`, `b`, `c`])]))
// optional
.parameter(`india`, z.string().optional())
.parameter(`juliet`, z.number().optional())
.parameter(`kilo`, z.boolean().optional())
.parameter(`lima`, z.enum([`a`, `b`, `c`]).optional())
.parameter(`mike`, z.union([z.string(), z.number(), z.enum([`a`, `b`, `c`])]).optional())
// end
.settings({ prompt: { when: [{ result: `rejected` }, { result: `omitted` }] } })
.parse()
console.log()
console.log(args)