"""Base class for slash commands."""

from __future__ import annotations

from abc import ABC, abstractmethod
from dataclasses import dataclass
from typing import TYPE_CHECKING, Callable

if TYPE_CHECKING:
    from clients.terminal.tui.context import TuiContext


@dataclass
class CommandMeta:
    name: str
    aliases: tuple[str, ...]
    description: str
    keybind: str | None = None


CommandHandler = Callable[["TuiContext", str], None]


class BaseCommand(ABC):
    """A slash command registered in the command palette."""

    meta: CommandMeta

    @abstractmethod
    async def execute(self, ctx: "TuiContext", args: str) -> None:
        """Run the command. args is the raw text after the command name."""
        raise NotImplementedError
