INNER CODE UNIT · Python

_print_json

marc-shade/world-intel-mcp · src/world_intel_mcp/cli.py:91

def _print_json(data: dict) -> None:
    """Print raw JSON if --json flag, otherwise formatted."""
    console.print_json(json.dumps(data, default=str))


def _bail_on_error(ctx: click.Context, data: dict) -> bool:
    """True when the command should stop rendering.

    In --json-output mode the raw dict (error included) is printed
    unchanged. In table mode an upstream {"error": ...} is printed in red
    so an outage is never shape-identical to a quiet world ("0
    earthquakes", "No market data available"). Degraded-but-partial
    payloads carry no top-level "error" key and fall through to normal
    rendering.
    """
    if ctx.obj.get("json"):
        _print_json(data)
        return True

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…