Rebrand the Rust client crate (coven/ → hh/, package+binary "hack-house"), README, CLI strings, and branch (coven → hack-house). Gitea repo renamed cmd-chat → hack-house to match. Crypto/server logic unchanged; selftest + golden-vector test still green, binary is now `hack-house`. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
32 lines
1000 B
Python
32 lines
1000 B
Python
from __future__ import annotations
|
|
|
|
from functools import wraps
|
|
from inspect import isawaitable
|
|
from typing import Callable
|
|
|
|
from sanic.base.meta import SanicMeta
|
|
from sanic.models.futures import FutureCommand
|
|
|
|
|
|
class CommandMixin(metaclass=SanicMeta):
|
|
def __init__(self, *args, **kwargs) -> None:
|
|
self._future_commands: set[FutureCommand] = set()
|
|
|
|
def command(
|
|
self, maybe_func: Callable | None = None, *, name: str = ""
|
|
) -> Callable | Callable[[Callable], Callable]:
|
|
def decorator(f):
|
|
@wraps(f)
|
|
async def decorated_function(*args, **kwargs):
|
|
response = f(*args, **kwargs)
|
|
if isawaitable(response):
|
|
response = await response
|
|
return response
|
|
|
|
self._future_commands.add(
|
|
FutureCommand(name or f.__name__, decorated_function)
|
|
)
|
|
return decorated_function
|
|
|
|
return decorator(maybe_func) if maybe_func else decorator
|