1import { VERSION } from "@nzip/shared";2import { main } from "./main.ts";34async function captureStdout(argv: string[]): Promise<string[]> {5 const lines: string[] = [];6 const original = console.log;7 console.log = (...args: unknown[]) => lines.push(args.map(String).join(" "));8 try {9 await main(argv);10 } finally {11 console.log = original;12 }13 return lines;14}1516Deno.test("version prints the installed CLI version without configuration", async () => {17 const lines = await captureStdout(["--version"]);18 if (lines.length !== 1 || lines[0] !== `nzip ${VERSION}`) {19 throw new Error(`unexpected version output: ${JSON.stringify(lines)}`);20 }21});2223Deno.test("version supports agent-readable JSON", async () => {24 const lines = await captureStdout(["--version", "--json"]);25 if (lines.length !== 1) throw new Error(`unexpected version output: ${JSON.stringify(lines)}`);2627 const output = JSON.parse(lines[0]);28 if (output.version !== VERSION) {29 throw new Error(`unexpected version JSON: ${lines[0]}`);30 }31});