feat: simplify CLI feature (#23)

* chore: cleanup + add tests

* chore: remove graph and show fixtures commands

* feat: add async_command wrapper
This commit is contained in:
d3vyce
2026-02-03 14:35:15 +01:00
committed by GitHub
parent 8c287b3ce7
commit 34ef4da317
7 changed files with 492 additions and 228 deletions

View File

@@ -0,0 +1,27 @@
"""CLI utility functions."""
import asyncio
import functools
from collections.abc import Callable, Coroutine
from typing import Any, ParamSpec, TypeVar
P = ParamSpec("P")
T = TypeVar("T")
def async_command(func: Callable[P, Coroutine[Any, Any, T]]) -> Callable[P, T]:
"""Decorator to run an async function as a sync CLI command.
Example:
@fixture_cli.command("load")
@async_command
async def load(ctx: typer.Context) -> None:
async with get_db_context() as session:
await load_fixtures(session, registry)
"""
@functools.wraps(func)
def wrapper(*args: P.args, **kwargs: P.kwargs) -> T:
return asyncio.run(func(*args, **kwargs))
return wrapper