from lark import Token, Tree

from dataclasses import dataclass
from typing import Self

from ..core.context import Context, ParseContext, Command, CommandResult
from ..core.commandparser import CommandArgumentParser, CommandArguments

@dataclass(slots=True)
class CommandArguments_Commandcommandname(CommandArguments):
    ...

@dataclass(slots=True)
class CommandResult_Commandcommandname(CommandResult):
    ...

parse_commandname_command = CommandArgumentParser(CommandArguments_Commandcommandname, 'commandname')


@dataclass(slots=True)
class Command_Commandcommandname(Command[CommandArguments_Commandcommandname, CommandResult_Commandcommandname]):
    @classmethod
    def parse(
        cls: type[Self], commandtoken: Token, tokens: list[Token | Tree[Token]], parsecontext: ParseContext
    ) -> Self:
        arguments = parse_commandname_command.parse(commandtoken, tokens)
        
        return cls(
            line=commandtoken.line or -1,
            name=commandtoken.value,
            args=arguments,
        )

    def execute(self, context: Context) -> CommandResult_Commandcommandname:
        raise NotImplementedError('Invalid command execution for template command "commandname".')
