diff --git a/kiwi_scp/commands/cmd_build.py b/kiwi_scp/commands/cmd_build.py index 2f5de78..57008a0 100644 --- a/kiwi_scp/commands/cmd_build.py +++ b/kiwi_scp/commands/cmd_build.py @@ -7,12 +7,14 @@ from ..instance import Instance, Project @kiwi_command( - cmd_type=KiwiCommandType.SERVICE, short_help="Build docker images", ) class BuildCommand(KiwiCommand): """Build images for the whole instance, a project or service(s) inside a project""" + type = KiwiCommandType.SERVICES + enabled_only = True + @classmethod def run_for_services(cls, instance: Instance, project: Project, service_names: List[str], **kwargs) -> None: COMPOSE_EXE.run(["build", "--pull", *service_names], **project.process_kwargs) diff --git a/kiwi_scp/commands/cmd_cmd.py b/kiwi_scp/commands/cmd_cmd.py index ebb181c..58996f7 100644 --- a/kiwi_scp/commands/cmd_cmd.py +++ b/kiwi_scp/commands/cmd_cmd.py @@ -18,7 +18,6 @@ from ..instance import Instance, Project metavar="COMMAND", ) @kiwi_command( - cmd_type=KiwiCommandType.PROJECT, short_help="Run docker-compose command", # ignore arguments looking like options # just pass everything down to docker-compose @@ -27,8 +26,10 @@ from ..instance import Instance, Project class CmdCommand(KiwiCommand): """Run raw docker-compose command in a project""" + type = KiwiCommandType.PROJECT + enabled_only = True + @classmethod 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) + COMPOSE_EXE.run([compose_cmd, *compose_args], **project.process_kwargs) diff --git a/kiwi_scp/commands/cmd_disable.py b/kiwi_scp/commands/cmd_disable.py index 69d0c77..adb1687 100644 --- a/kiwi_scp/commands/cmd_disable.py +++ b/kiwi_scp/commands/cmd_disable.py @@ -11,11 +11,11 @@ from ..instance import Instance, Project "--force/--no-force", help=f"skip confirmation", ) -@kiwi_command( - cmd_type=KiwiCommandType.PROJECT, -) +@kiwi_command() class DisableCommand(KiwiCommand): - """Disable a project""" + """Disable project(s)""" + + type = KiwiCommandType.PROJECTS @classmethod def run_for_instance(cls, instance: Instance, force: bool = None) -> None: diff --git a/kiwi_scp/commands/cmd_down.py b/kiwi_scp/commands/cmd_down.py index 80e4bec..b055328 100644 --- a/kiwi_scp/commands/cmd_down.py +++ b/kiwi_scp/commands/cmd_down.py @@ -14,12 +14,14 @@ from ..instance import Instance, Project, Services help=f"skip confirmation", ) @kiwi_command( - cmd_type=KiwiCommandType.SERVICE, short_help="Bring down kiwi services", ) class DownCommand(KiwiCommand): """Bring down the whole instance, a project or service(s) inside a project""" + type = KiwiCommandType.SERVICES + enabled_only = True + @classmethod def run_for_instance(cls, instance: Instance, force: bool = None) -> None: if not force: diff --git a/kiwi_scp/commands/cmd_enable.py b/kiwi_scp/commands/cmd_enable.py index d0e952e..580644a 100644 --- a/kiwi_scp/commands/cmd_enable.py +++ b/kiwi_scp/commands/cmd_enable.py @@ -11,11 +11,11 @@ from ..instance import Instance, Project "--force/--no-force", help=f"skip confirmation", ) -@kiwi_command( - cmd_type=KiwiCommandType.PROJECT, -) +@kiwi_command() class DisableCommand(KiwiCommand): - """Enable a project""" + """Enable project(s)""" + + type = KiwiCommandType.PROJECTS @classmethod def run_for_instance(cls, instance: Instance, force: bool = None) -> None: diff --git a/kiwi_scp/commands/cmd_init.py b/kiwi_scp/commands/cmd_init.py index dc4b8f5..ab8ee98 100644 --- a/kiwi_scp/commands/cmd_init.py +++ b/kiwi_scp/commands/cmd_init.py @@ -30,12 +30,13 @@ _logger = logging.getLogger(__name__) help=f"use default values even if {KIWI_CONF_NAME} is present", ) @kiwi_command( - cmd_type=KiwiCommandType.INSTANCE, short_help="Initializes kiwi-scp", ) class InitCommand(KiwiCommand): """Initialize or reconfigure a kiwi-scp instance""" + type = KiwiCommandType.INSTANCE + @classmethod def run_for_instance(cls, instance: Instance, directory: Path = None, force: bool = None) -> None: if directory is not None: diff --git a/kiwi_scp/commands/cmd_list.py b/kiwi_scp/commands/cmd_list.py index 0dca29d..5c98568 100644 --- a/kiwi_scp/commands/cmd_list.py +++ b/kiwi_scp/commands/cmd_list.py @@ -13,12 +13,13 @@ from ..instance import Instance, Project help=f"show actual config contents instead", ) @kiwi_command( - cmd_type=KiwiCommandType.SERVICE, short_help="Inspect a kiwi-scp instance", ) class ListCommand(KiwiCommand): """List projects in this instance, services inside a project or service(s) inside a project""" + type = KiwiCommandType.SERVICES + @classmethod def run_for_instance(cls, instance: Instance, show: bool = None) -> None: if show: @@ -43,7 +44,8 @@ class ListCommand(KiwiCommand): KiwiCommand.print_list(service.name for service in project.services.content) @classmethod - def run_for_services(cls, instance: Instance, project: Project, service_names: List[str], show: bool = None) -> None: + def run_for_services(cls, instance: Instance, project: Project, service_names: List[str], + show: bool = None) -> None: services = project.services.filter_existing(service_names) if show: service_names = [service.name for service in services.content] diff --git a/kiwi_scp/commands/cmd_up.py b/kiwi_scp/commands/cmd_up.py index 193cc77..8485bdb 100644 --- a/kiwi_scp/commands/cmd_up.py +++ b/kiwi_scp/commands/cmd_up.py @@ -8,13 +8,13 @@ from ..executable import COMPOSE_EXE from ..instance import Instance, Project, Services -@kiwi_command( - cmd_type=KiwiCommandType.SERVICE, - short_help="Bring up kiwi services", -) +@kiwi_command(short_help="Bring up kiwi services") class UpCommand(KiwiCommand): """Bring up the whole instance, a project or service(s) inside a project""" + type = KiwiCommandType.SERVICES + enabled_only = True + @classmethod def run_for_filtered_services(cls, instance: Instance, project: Project, services: Services, new_service_names: List[str], **kwargs) -> None: