({ args })
| 72 | }, |
| 73 | // fallow-ignore-next-line complexity |
| 74 | async run({ args }) { |
| 75 | if (args.video) { |
| 76 | const { runVideoMode } = await import("./capture/video.js"); |
| 77 | await runVideoMode({ |
| 78 | project: args.video as string, |
| 79 | index: (args.index as string | undefined) ?? null, |
| 80 | url: (args["video-url"] as string | undefined) ?? null, |
| 81 | list: args.list as boolean, |
| 82 | }); |
| 83 | return; |
| 84 | } |
| 85 | |
| 86 | const url = args.url as string | undefined; |
| 87 | if (!url) { |
| 88 | console.error( |
| 89 | "Missing URL. Pass a website URL, or use --video <project> for video download.", |
| 90 | ); |
| 91 | process.exit(1); |
| 92 | } |
| 93 | |
| 94 | try { |
| 95 | new URL(url); |
| 96 | } catch { |
| 97 | console.error(`Invalid URL: ${url}`); |
| 98 | process.exit(1); |
| 99 | } |
| 100 | |
| 101 | const isDefaultOutput = !args.output; |
| 102 | let outputName = (args.output as string | undefined) ?? "capture"; |
| 103 | let outputDir = resolve(outputName); |
| 104 | |
| 105 | if (isDefaultOutput) { |
| 106 | const { existsSync } = await import("node:fs"); |
| 107 | // Auto-suffix when ./capture/ is taken: capture-2, capture-3, … so re-runs |
| 108 | // never silently merge into a previous capture's artifacts. |
| 109 | let n = 2; |
| 110 | while (existsSync(outputDir) && n < 100) { |
| 111 | outputName = `capture-${n}`; |
| 112 | outputDir = resolve(outputName); |
| 113 | n++; |
| 114 | } |
| 115 | if (existsSync(outputDir)) { |
| 116 | console.error(`./capture-{2..99} are all taken. Pass -o <name> to pick a directory.`); |
| 117 | process.exit(1); |
| 118 | } |
| 119 | } |
| 120 | |
| 121 | const isJson = args.json as boolean; |
| 122 | |
| 123 | if (!isJson) { |
| 124 | const { c } = await import("../ui/colors.js"); |
| 125 | console.log(); |
| 126 | console.log(c.dim("◆") + " Capturing " + c.bold(url)); |
| 127 | if (isDefaultOutput && outputName !== "capture") { |
| 128 | console.log(` ${c.dim(`(./capture/ exists; writing to ./${outputName}/)`)}`); |
| 129 | } |
| 130 | console.log(); |
| 131 | } |
nothing calls this directly
no test coverage detected