1
0
Fork 0
mirror of https://github.com/yavook/kiwi-scp.git synced 2024-12-25 18:42:59 +00:00

subcommand "conf-clean"

This commit is contained in:
Jörn-Michael Miehe 2020-08-18 17:49:49 +02:00
parent f9cb784760
commit b3456f8ec3
2 changed files with 39 additions and 1 deletions

View file

@ -1,7 +1,7 @@
# local
from .build import BuildCommand
from .cmd import CmdCommand
from .conf import ConfCopyCommand, ConfPurgeCommand
from .conf import ConfCopyCommand, ConfPurgeCommand, ConfCleanCommand
from .disable import DisableCommand
from .down import DownCommand
from .enable import EnableCommand
@ -22,6 +22,7 @@ __all__ = [
'CmdCommand',
'ConfCopyCommand',
'ConfPurgeCommand',
'ConfCleanCommand',
'DisableCommand',
'DownCommand',
'EnableCommand',

View file

@ -62,3 +62,40 @@ class ConfPurgeCommand(SubCommand):
)
return True
class ConfCleanCommand(SubCommand):
"""kiwi conf-clean"""
def __init__(self):
super().__init__(
'conf-clean',
description="Cleanly sync all configs to target folder, relaunch affected projects"
)
def run(self, runner, config, args):
result = True
# down all projects with config directories
affected_projects = []
for project_name in list_projects(config):
project_conf = f"{get_project_dir(config, project_name)}/{CONF_DIRECTORY_NAME}"
if os.path.isdir(project_conf):
affected_projects.append(project_name)
for project_name in affected_projects:
args.projects = project_name
result &= runner.run('down')
# cleanly sync configs
result &= runner.run('conf-purge')
result &= runner.run('conf-purge')
# bring projects back up
for project_name in affected_projects:
args.projects = project_name
result &= runner.run('up')
return result