capture.py
python
sha256:a78e7e5a8740e03315f325d19edeb3aa1b306b3337d04abbaa9a9e0f3bbeb7a1
docs: MuseHub-first before ISR #74 — staging solidify NEXT
Human
13 hours ago
| 1 | """Capture JSON emitted by CLI commands for HTTP handlers.""" |
| 2 | |
| 3 | from __future__ import annotations |
| 4 | |
| 5 | from typing import Any |
| 6 | |
| 7 | from cli.output import OutputContext |
| 8 | |
| 9 | |
| 10 | class CapturingOutputContext(OutputContext): |
| 11 | """Output context that records the last JSON payload instead of printing it.""" |
| 12 | |
| 13 | def __init__(self) -> None: |
| 14 | super().__init__(json_mode=True, quiet=True) |
| 15 | self.json_payload: dict[str, Any] | None = None |
| 16 | |
| 17 | def emit_json(self, payload: dict[str, Any]) -> None: |
| 18 | self.json_payload = payload |
File History
1 commit
sha256:a78e7e5a8740e03315f325d19edeb3aa1b306b3337d04abbaa9a9e0f3bbeb7a1
docs: MuseHub-first before ISR #74 — staging solidify NEXT
Human
13 hours ago