You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Let's have a new export Parameter that allows building a parameter that can be passed to .parameter or .parameters.
parameters is a new method that accepts an array of parameters.
Some type concepts will move to it: description, optionality
How will the extension system work?
Allow extensions to extend the parameter builder
But we don't need it, in the sense that the mapping of zod to parameter can be a pure function
We can revisit extensions in the future
The reason it doesn't work fully is because of the concepts zod brings into the type like optionality and description... but anyways it doesn't seem like the zod part matters much, we can start a bit fresh... we can
User can alias Parameter to _ for clean code (see example below)
a .type method accepts a Type builder
c, p, t can be named exports that alias Command, Parameter, Type
methods for each t method like .string() and .boolean() that then adjust the typing of .default() if given after
validation methods after the type has been given
.name is a constructor method
Examples:
constargs=awaitCommand.name('intro').parameters([_.name('filePath').type(zod(z.string())).description(`Path to the file to convert.`),_.name('to').type(zod(z.enum([`json`,`yaml`,`toml`]))).description(`Format to convert to.`),_.name(`from`).enum([`json`,`yaml`,`toml`]).optional(),_.name(`verbose v`).boolean().default(false).description(`Log detailed progress as conversion executes.`),_.name(`move m`).type(t.boolean()).default(false).description(`Delete the original file after it has been converted.`),]).settings({prompt: {// TODO allow making parameter level opt-in or opt-out// default: false,when: [{result: `rejected`,error: `ErrorMissingArgument`,},{result: `omitted`},],},}).parse()
constargs=awaitCommand.name('intro').parameter('filePath',{type: zod(z.string()),description: `Path to the file to convert.`,}).parameter(`to`,{type: zod(z.enum([`json`,`yaml`,`toml`])),description: `Format to convert to.`,}).parameter(`from`,{type: zod(z.enum([`json`,`yaml`,`toml`])),optionality: Optionality.optional(),}).parameter(`verbose v`,{type: zod(z.boolean()),optionality: Optionality.default(false),description: `Log detailed progress as conversion executes.`,}).parameter(`move m`,{type: zod(z.boolean().default(false).describe(`Delete the original file after it has been converted.`)),}).settings({prompt: {// TODO allow making parameter level opt-in or opt-out// default: false,when: [{result: `rejected`,error: `ErrorMissingArgument`,},{result: `omitted`},],},}).parse()
The text was updated successfully, but these errors were encountered:
Parameter
that allows building a parameter that can be passed to.parameter
or.parameters
.parameters
is a new method that accepts an array of parameters.description
,optionality
Parameter
to_
for clean code (see example below).type
method accepts a Type builderc, p, t
can be named exports that aliasCommand, Parameter, Type
t
method like.string()
and.boolean()
that then adjust the typing of.default()
if given after.name
is a constructor methodExamples:
The text was updated successfully, but these errors were encountered: