"""Step definitions for complete main module coverage tests."""

from behave import then, when


@when("I run the __main__ module as a script with --version")
def step_run_main_as_script(context):
    """Run the __main__ module via in-process CliRunner (avoids subprocess)."""
    from typer.testing import CliRunner

    from cleveragents.cli.main import app as main_app

    runner = CliRunner()
    result = runner.invoke(main_app, ["--version"])
    context.result = result
    context.exit_code = result.exit_code
    context.output = result.output or ""


@then("the version should be displayed")
def step_check_version_displayed(context):
    """Check that the version is displayed."""
    assert "CleverAgents" in context.output or "cleveragents" in context.output.lower()
