import * as path from "https://deno.land/std@0.87.0/path/mod.ts"; import { readLines } from "https://deno.land/std@0.87.0/io/mod.ts"; import { parse } from "https://deno.land/std@0.87.0/flags/mod.ts"; import { Base64 } from "https://deno.land/x/bb64@1.1.0/mod.ts"; interface LogEntry { log: string; stream: "stdout"; time: Date; } const encoder = new TextEncoder(); const options = parse(Deno.args, { boolean: true }); for (const filename of options._ as string[]) { let imageReading = false; let imageBase64Buffer = ""; let imageFilename = ""; const file = await Deno.open(filename); for await (const line of readLines(file)) { if (line) { const parsedLine = JSON.parse( line, (key, value) => key === "time" ? new Date(value) : value, ) as LogEntry; if (options.files) { const startOfFileMatches = parsedLine.log.match(/>>>> file:(.+)/); if (startOfFileMatches) { imageReading = true; imageFilename = startOfFileMatches[1]; console.log("File found:", imageFilename); continue; } const endOfFileMatches = parsedLine.log.match(/(.+)<<<