from typing import List

from ._LineParser import (
    LineParser,
    JSON,
)
from ._CommandLineParser import CommandLineParser


class Line(object):

    @staticmethod
    def parse(
        line,       # type: JSON
        columns,    # type: int
    ):
        # type: (...) -> List[str]

        if "command" in line:
            return CommandLineParser(columns=columns).parse(line=line)
        elif "text" in line:
            return LineParser(columns=columns).parse(line=line)

        return CommandLineParser(columns=columns).parse(
            line={
                "command": "{CMD_BREAK_LINE}"
            }
        )
