cmd-ts
cmd-ts copied to clipboard
Add a `object` combinator
The basic should be the same as command
, and maybe command
should use it internally:
object({
someName: ArgParser<T>,
otherName: ArgParser<R>,
}) => ArgParser<{ someName: T, otherName: R }>
I have implemented it. Wasn't hard. But I'm not sure that it is far better than:
const extended = {
someName: myParser(),
otherName: otherName(),
} as const
command({
args: { ...extended }
...
})
Maybe I will do it just for the sake of single responsibility, the command
function is fairly large. Extracting the object parsing into an object
would kinda make sense for maintainability.