from ._utils import api_util
from .Bases import Base


class IText(Base):
    __slots__ = []

    __name__ = "Text"
    _api_prefix = "Text"
    _columns = []

    def Command(self, *args):
        """
        Input command string for the DSS.

        Original COM help: https://opendss.epri.com/Command1.html
        """
        # Getter
        if len(args) == 0:
            return self._lib.Text_Get_Command()

        # Setter
        (Value,) = args
        self._lib.Text_Set_Command(Value)

    def Result(self):
        """
        Result string for the last command.

        Original COM help: https://opendss.epri.com/Result.html
        """
        return self._lib.Text_Get_Result()

    def Commands(self, Value):
        """
        Runs a list of strings or a large string as commands directly in the DSS engine.
        Intermediate results (from Text.Result) are ignored.

        Value can be a list of strings, or a single large string (usually faster).

        **(API Extension)**
        """
        if isinstance(Value, (str, bytes)):
            self._lib.Text_CommandBlock(Value)
        else:
            self._set_string_array(self._lib.Text_CommandArray, Value)


_Text = IText(api_util)

# For backwards compatibility, bind to the default instance
Command = _Text.Command
Commands = _Text.Commands
Result = _Text.Result
_columns = _Text._columns
__all__ = ["Command", "Commands", "Result"]
