Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion openagent_eval/cli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import typer
from rich.console import Console

from openagent_eval import __version__
from openagent_eval.cli.banner import create_mini_banner
from openagent_eval.cli.commands.compare import compare_command
from openagent_eval.cli.commands.delete import delete_command
Expand All @@ -21,7 +22,7 @@
from openagent_eval.cli.commands.validate import validate_command
from openagent_eval.cli.commands.audit import audit_command
from openagent_eval.cli.context import CLIContext, set_context
from openagent_eval.cli.utils.callbacks import version_callback
from openagent_eval.cli.utils.callbacks import VERSION_OPTION, version_callback
from openagent_eval.exceptions import OpenAgentEvalError

# Error code mapping for different exception types
Expand Down Expand Up @@ -475,3 +476,17 @@ def _cli_exception_handler(exc_type: type, exc_value: BaseException, exc_tb: obj

# Install custom exception handler
sys.excepthook = _cli_exception_handler


def _version_aware_cli() -> None:
"""CLI entry point that also responds to ``--version`` in subcommand position.

Typer requires callback options (e.g. ``--version``) to appear *before*
the subcommand token. This wrapper scans ``sys.argv`` so that
``oaeval run --version`` prints the version and exits.
"""
for token in sys.argv[1:]:
if token in ("--version", "-V"):
typer.echo(f"OpenAgent Eval v{__version__}")
raise SystemExit(0)
app()
10 changes: 10 additions & 0 deletions openagent_eval/cli/utils/callbacks.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,13 @@ def version_callback(value: bool) -> None:

typer.echo(f"OpenAgent Eval v{__version__}")
raise typer.Exit()


VERSION_OPTION = typer.Option(
False,
"--version",
"-V",
help="Show version and exit.",
callback=version_callback,
is_eager=True,
)
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ all = [
]

[project.scripts]
oaeval = "openagent_eval.cli.main:app"
oaeval = "openagent_eval.cli.main:_version_aware_cli"

[project.entry-points."openagent_eval.metrics"]
# Custom metrics can be registered here
Expand Down
Loading