diff --git a/kiwi_scp/commands/cli.py b/kiwi_scp/commands/cli.py index 4929d27..cf30a1e 100644 --- a/kiwi_scp/commands/cli.py +++ b/kiwi_scp/commands/cli.py @@ -122,17 +122,17 @@ class KiwiCommand: def run_for_instance(cls, instance: Instance, **kwargs) -> None: for project_config in instance.config.projects: project = instance.get_project(project_config.name) - cls.run_for_existing_project(instance, project, **kwargs) + cls.run_for_project(instance, project, **kwargs) + + @classmethod + def run_for_project(cls, instance: Instance, project: Project, **kwargs) -> None: + service_names = [service.name for service in project.services.content] + cls.run_for_services(instance, project, service_names, **kwargs) @classmethod def run_for_new_project(cls, instance: Instance, project_name: str, **kwargs) -> None: cls.print_error(f"Project '{project_name}' not in kiwi-scp instance at '{instance.directory}'!") - @classmethod - def run_for_existing_project(cls, instance: Instance, project: Project, **kwargs) -> None: - service_names = [service.name for service in project.services.content] - cls.run_for_services(instance, project, service_names, **kwargs) - @classmethod def run_for_services(cls, instance: Instance, project: Project, service_names: List[str], **kwargs) -> None: raise Exception diff --git a/kiwi_scp/commands/cmd_cmd.py b/kiwi_scp/commands/cmd_cmd.py index d0bc116..ebb181c 100644 --- a/kiwi_scp/commands/cmd_cmd.py +++ b/kiwi_scp/commands/cmd_cmd.py @@ -28,7 +28,7 @@ class CmdCommand(KiwiCommand): """Run raw docker-compose command in a project""" @classmethod - def run_for_existing_project(cls, instance: Instance, project: Project, compose_cmd: str = None, - compose_args: Tuple[str] = None) -> None: + def run_for_project(cls, instance: Instance, project: Project, compose_cmd: str = None, + compose_args: Tuple[str] = None) -> None: if project.project_config.enabled: COMPOSE_EXE.run([compose_cmd, *compose_args], **project.process_kwargs) diff --git a/kiwi_scp/commands/cmd_down.py b/kiwi_scp/commands/cmd_down.py index 59bf376..28ab477 100644 --- a/kiwi_scp/commands/cmd_down.py +++ b/kiwi_scp/commands/cmd_down.py @@ -36,7 +36,7 @@ class DownCommand(KiwiCommand): # TODO net-down @classmethod - def run_for_existing_project(cls, instance: Instance, project: Project, **kwargs) -> None: + def run_for_project(cls, instance: Instance, project: Project, **kwargs) -> None: COMPOSE_EXE.run(["down"], **project.process_kwargs) @classmethod diff --git a/kiwi_scp/commands/cmd_list.py b/kiwi_scp/commands/cmd_list.py index cb8f2e6..092c8f9 100644 --- a/kiwi_scp/commands/cmd_list.py +++ b/kiwi_scp/commands/cmd_list.py @@ -33,7 +33,7 @@ class ListCommand(KiwiCommand): ) @classmethod - def run_for_existing_project(cls, instance: Instance, project: Project, show: bool = None) -> None: + def run_for_project(cls, instance: Instance, project: Project, show: bool = None) -> None: if show: KiwiCommand.print_header(f"Showing config for all services in project '{project.name}'.") click.echo_via_pager(str(project.services)) diff --git a/kiwi_scp/commands/decorators.py b/kiwi_scp/commands/decorators.py index 76b5238..22e5aec 100644 --- a/kiwi_scp/commands/decorators.py +++ b/kiwi_scp/commands/decorators.py @@ -53,7 +53,7 @@ def kiwi_command( project = ctx.get_project(project_name) if project is not None: _logger.debug(f"running for existing project {project}, kwargs={kwargs}") - command_cls.run_for_existing_project(ctx, project, **kwargs) + command_cls.run_for_project(ctx, project, **kwargs) else: _logger.debug(f"running for new project {project_name}, kwargs={kwargs}")