Removed Clutter

This commit is contained in:
Jörn-Michael Miehe 2021-11-13 01:12:27 +01:00
parent 2e37291a68
commit e7e6e5867a
3 changed files with 6 additions and 11 deletions

View file

@ -5,7 +5,7 @@ from typing import List, Tuple, Iterable, Any, Type
import click import click
from ..instance import Instance, Project, Services from ..instance import Instance, Project
class KiwiCLI(click.MultiCommand): class KiwiCLI(click.MultiCommand):
@ -83,7 +83,7 @@ class KiwiCommand:
@classmethod @classmethod
def run_for_new_project(cls, instance: Instance, project_name: str, **kwargs) -> None: def run_for_new_project(cls, instance: Instance, project_name: str, **kwargs) -> None:
raise Exception cls.print_error(f"Project '{project_name}' not in kiwi-scp instance at '{instance.directory}'!")
@classmethod @classmethod
def run_for_existing_project(cls, instance: Instance, project: Project, **kwargs) -> None: def run_for_existing_project(cls, instance: Instance, project: Project, **kwargs) -> None:

View file

@ -38,7 +38,7 @@ class CMD(KiwiCommand):
"""Initialize or reconfigure a kiwi-scp instance""" """Initialize or reconfigure a kiwi-scp instance"""
@classmethod @classmethod
def run_for_instance(cls, instance: Instance, output: Path = None, force: bool = None, **kwargs) -> None: def run_for_instance(cls, instance: Instance, output: Path = None, force: bool = None) -> None:
if output is not None: if output is not None:
instance.directory = output instance.directory = output

View file

@ -21,7 +21,7 @@ class CMD(KiwiCommand):
"""List projects in this instance, services inside a project or service(s) inside a project""" """List projects in this instance, services inside a project or service(s) inside a project"""
@classmethod @classmethod
def run_for_instance(cls, instance: Instance, show: bool = None, **kwargs) -> None: def run_for_instance(cls, instance: Instance, show: bool = None) -> None:
if show: if show:
KiwiCommand.print_header(f"Showing config for kiwi-scp instance at '{instance.directory}'.") KiwiCommand.print_header(f"Showing config for kiwi-scp instance at '{instance.directory}'.")
click.echo_via_pager(instance.config.kiwi_yml) click.echo_via_pager(instance.config.kiwi_yml)
@ -34,7 +34,7 @@ class CMD(KiwiCommand):
) )
@classmethod @classmethod
def run_for_existing_project(cls, instance: Instance, project: Project, show: bool = None, **kwargs) -> None: def run_for_existing_project(cls, instance: Instance, project: Project, show: bool = None) -> None:
if show: if show:
KiwiCommand.print_header(f"Showing config for all services in project '{project.name}'.") KiwiCommand.print_header(f"Showing config for all services in project '{project.name}'.")
click.echo_via_pager(str(project.services)) click.echo_via_pager(str(project.services))
@ -44,12 +44,7 @@ class CMD(KiwiCommand):
KiwiCommand.print_list(service.name for service in project.services.content) KiwiCommand.print_list(service.name for service in project.services.content)
@classmethod @classmethod
def run_for_new_project(cls, instance: Instance, project_name: str, **kwargs) -> None: def run_for_services(cls, instance: Instance, project: Project, service_names: List[str], show: bool = None) -> None:
KiwiCommand.print_error(f"Project '{project_name}' not in kiwi-scp instance at '{instance.directory}'!")
@classmethod
def run_for_services(cls, instance: Instance, project: Project, service_names: List[str], show: bool = None,
**kwargs) -> None:
services = project.services.filter_existing(service_names) services = project.services.filter_existing(service_names)
if show: if show:
service_names = [service.name for service in services.content] service_names = [service.name for service in services.content]