@xiniha 네네, Zod를 쓰는 건 아니고 Zod 스타일로 파싱 결과의 타입 구조를 선언할 수 있게 하려고 했습니다. 대충 아래와 같은 느낌이 되려나요?

const parser: Parser<
  {
    readonly options: { readonly type: "socket"; readonly socket: string } | {
      readonly type: "listen";
      readonly host: string;
      readonly port: number;
    };
  } & {
    readonly name: string;
    readonly arguments: ReadonlyArray<string>;
  }
> = and(
  object({
    options: or(
      object("File socket options", {
        type: constant("socket"),
        socket: option("-s", "--socket", filePath()),
      }),
      object("Listening options", {
        type: constant("listen"),
        host: option("-h", "--host", string()),
        port: option("-p", "--port", integer()),
      }),
    ),
  }),
  object("Arguments", {
    name: argument(string()),
    files: multiple(argument(filePath()), 1),
  }),
);
1

If you have a fediverse account, you can quote this note from your own instance. Search https://hackers.pub/ap/notes/01985048-03de-73f8-ba89-e84289eef484 on your instance and quote it. (Note that quoting is not supported in Mastodon.)