diff --git a/kiwi_scp/commands/cmd_init.py b/kiwi_scp/commands/cmd_init.py index a93d565..a5ae22d 100644 --- a/kiwi_scp/commands/cmd_init.py +++ b/kiwi_scp/commands/cmd_init.py @@ -68,6 +68,4 @@ class InitCommand(KiwiCommand): os.mkdir(instance.directory) # write out the new kiwi.yml - cfg = KiwiConfig.parse_obj(kiwi_dict) - with open(instance.directory.joinpath(KIWI_CONF_NAME), "w") as file: - cfg.dump_kiwi_yml(file) + instance.save_config(KiwiConfig.parse_obj(kiwi_dict)) diff --git a/kiwi_scp/instance.py b/kiwi_scp/instance.py index 30389e7..9f41977 100644 --- a/kiwi_scp/instance.py +++ b/kiwi_scp/instance.py @@ -3,6 +3,7 @@ from typing import Generator, Dict, Sequence import attr +from ._constants import KIWI_CONF_NAME from .config import KiwiConfig from .project import Project @@ -17,6 +18,10 @@ class Instance: return KiwiConfig.from_directory(self.directory) + def save_config(self, config: KiwiConfig) -> None: + with open(self.directory.joinpath(KIWI_CONF_NAME), "w") as file: + config.dump_kiwi_yml(file) + @property def projects(self) -> Generator[Project, None, None]: for project in self.config.projects: