from pathlib import Path
from typing import Sequence

from clarabot_nano.common.filesystem.operation.base import AbstractIOQueueOperation


class MkdirOperation(AbstractIOQueueOperation):
    OPERATION_KEY = "MKD"

    def __init__(self, account_id: int, path: str, parents: bool = False, exist_ok: bool = False):
        AbstractIOQueueOperation.__init__(self, account_id)
        self.path = path
        self.parents = parents
        self.exist_ok = exist_ok

    def paths(self) -> Sequence[str]:
        return (self.path,)

    def execute(self):
        Path(self.path).mkdir(parents=self.parents, exist_ok=self.exist_ok)
