From e9622c3ac21e0e08de15263a82f77b3828aecaa9 Mon Sep 17 00:00:00 2001 From: Ivan Ogasawara Date: Mon, 5 Jun 2023 18:18:10 -0400 Subject: [PATCH] fix(ext): Fix restart and start ext commands (#79) --- containers_sugar/sugar.py | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/containers_sugar/sugar.py b/containers_sugar/sugar.py index bd3dfd5..64f92c2 100644 --- a/containers_sugar/sugar.py +++ b/containers_sugar/sugar.py @@ -229,7 +229,7 @@ def run(self): return getattr(self, f'_{action.replace("-", "_")}')() -class SugarMain(SugarBase): +class SugarDockerCompose(SugarBase): """ This is the docker-compose commands that is implemented: @@ -384,30 +384,41 @@ def _version(self): self._call_compose_app('version', services=self.service_names) -class SugarExt(SugarMain): +class SugarExt(SugarDockerCompose): def __init__(self, *args, **kwargs): self.actions += [ - 'start', 'get-ip', + 'restart', + 'start', 'wait', ] super().__init__(*args, **kwargs) - def _start(self): - self._up() - def _get_ip(self): self._print_error('[EE] `get-ip` mot implemented yet.') os._exit(1) + def _restart(self): + options = self.options_args + self.options_args = [] + self._stop() + self.options_args = options + self._start() + + def _start(self): + self._up() + def _wait(self): self._print_error('[EE] `wait` not implemented yet.') os._exit(1) class Sugar(SugarBase, PrintPlugin): - plugins_definition: Dict[str, type] = {'main': SugarMain, 'ext': SugarExt} + plugins_definition: Dict[str, type] = { + 'main': SugarDockerCompose, + 'ext': SugarExt, + } plugin: Optional[SugarBase] = None def __init__(