A tiny starter project that shows how CodeHub repositories work.

feat: add --json output flag #1

Openada wants to merge feat/json-output into main
Conversation2 files changed+16−2
ALadaopened this pull request 5 days ago

Adds a --json flag that emits newline-delimited JSON.

Closes #1.

Files changed+16 −2
README.md+7−0
@@ -18,3 +18,10 @@ npm run dev
Then open http://localhost:3000 and sign in with the demo account.
+
+## JSON output
+
+```bash
+hello-codehub --json
+```
src/index.ts+9−2
@@ -1,4 +1,11 @@
import { greet } from "./utils.js";
const name = process.argv[2] ?? "world";
-console.log(greet(name));
+const asJson = process.argv.includes("--json");
+
+if (asJson) {
+ console.log(JSON.stringify({ message: greet(name), version: "1.0.0" }));
+} else {
+ console.log(greet(name));
+}
Reviews1 approved · 0 changes requested
GHgrace approved3 days ago

Looks good — the streaming path is clean and the fallback is covered.

TOoctocatcommented 4 days ago

This is exactly the shape I wanted. Could you add a test for the JSON path?

ALadacommented 3 days ago

Added one in a follow-up commit — streaming keeps memory flat for large outputs.

Sign in to review this pull request.