···8080const input = JSON.parse(Deno.args[0]);
81818282if (input.command === "fetch") {
8383- const { entrypoint, port } = input;
8483 Deno.serve(
8584 {
8686- port: parseInt(port),
8585+ port: parseInt(input.port),
8786 onListen: () => {
8887 // This line will signal that the server is ready to the go
8988 console.error("READY");
···9190 },
9291 async (req) => {
9392 try {
9494- const mod = await import(entrypoint);
9393+ const mod = await import(input.entrypoint);
9594 if (!mod.default) {
9695 return new Response("The app does not provide a default export.", { status: 500 });
9796 }
···136135 },
137136 );
138137} else if (input.command === "run") {
139139- const { entrypoint, args } = input;
140140- const mod = await import(entrypoint);
138138+ const mod = await import(input.entrypoint);
141139 if (!mod.default || typeof mod.default !== "object") {
142140 console.error(
143141 "The mod does not provide an object as it's default export.",
···156154 Deno.exit(1);
157155 }
158156159159- await handler.run(args);
157157+ await handler.run(input.args);
158158+} else if (input.command == "email") {
159159+ const { entrypoint } = input;
160160+ const mod = await import(entrypoint);
161161+ if (!mod.default || typeof mod.default !== "object") {
162162+ console.error(
163163+ "The mod does not provide an object as it's default export.",
164164+ );
165165+ Deno.exit(1);
166166+ }
167167+168168+ const handler = mod.default;
169169+ if (!("email" in handler)) {
170170+ console.error("The mod default export does not have a email function.");
171171+ Deno.exit(1);
172172+ }
173173+174174+ if (!(typeof handler.email === "function")) {
175175+ console.error("The mod default export email property must be a function.");
176176+ Deno.exit(1);
177177+ }
178178+179179+ await handler.email(Deno.stdin.readable);
160180} else {
161181 console.error("Unknown command");
162182 Deno.exit(1);