Skip to content

Commit 0fa0e8f

Browse files
committed
cli/output(fix[formatter]): restore stdout emission
1 parent 85e511a commit 0fa0e8f

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

src/vcspull/cli/_output.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
from __future__ import annotations
44

5+
import json
56
import sys
67
import typing as t
78
from dataclasses import dataclass, field
@@ -185,6 +186,7 @@ def emit(self, data: dict[str, t.Any] | PlanEntry | PlanSummary) -> None:
185186

186187
if self.mode == OutputMode.NDJSON:
187188
# Stream one JSON object per line immediately
189+
sys.stdout.write(json.dumps(payload) + "\n")
188190
sys.stdout.flush()
189191
elif self.mode == OutputMode.JSON:
190192
# Buffer for later output as single array
@@ -200,11 +202,14 @@ def emit_text(self, text: str) -> None:
200202
Text to output
201203
"""
202204
if self.mode == OutputMode.HUMAN:
203-
pass
205+
sys.stdout.write(text + "\n")
206+
sys.stdout.flush()
204207

205208
def finalize(self) -> None:
206209
"""Finalize output (flush JSON buffer if needed)."""
207210
if self.mode == OutputMode.JSON and self._json_buffer:
211+
sys.stdout.write(json.dumps(self._json_buffer, indent=2) + "\n")
212+
sys.stdout.flush()
208213
self._json_buffer.clear()
209214

210215

src/vcspull/cli/sync.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
import asyncio
66
import contextlib
7+
import json
78
import logging
89
import os
910
import pathlib
@@ -499,8 +500,9 @@ def _emit_plan_output(
499500
formatter.emit(entry)
500501
formatter.emit(plan.summary)
501502
return
502-
503-
PlanResult(entries=display_entries, summary=plan.summary)
503+
structured = PlanResult(entries=display_entries, summary=plan.summary)
504+
sys.stdout.write(json.dumps(structured.to_json_object(), indent=2) + "\n")
505+
sys.stdout.flush()
504506

505507

506508
def create_sync_subparser(parser: argparse.ArgumentParser) -> argparse.ArgumentParser:

0 commit comments

Comments
 (0)