"""Shared CLI harness for focused check-in test modules."""

from __future__ import annotations

import json
from pathlib import Path

from typer.testing import CliRunner

from checkin_cli.cli import app


RUNNER = CliRunner()


def invoke(home: Path, *args: str) -> dict[str, str]:
    """Run the public CLI and decode its structured response."""
    result = RUNNER.invoke(app, ["--home", str(home), *args])
    assert result.exit_code == 0, result.output
    return json.loads(result.output)
