cmd-ts icon indicating copy to clipboard operation
cmd-ts copied to clipboard

Add a `object` combinator

Open Schniz opened this issue 4 years ago • 1 comments

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 }>

Schniz avatar May 10 '20 08:05 Schniz

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.

Schniz avatar Feb 14 '21 14:02 Schniz