From fc55e9d677a0cb08d41c6044185259cdfac8b353 Mon Sep 17 00:00:00 2001 From: ldericher <40151420+ldericher@users.noreply.github.com> Date: Thu, 28 Oct 2021 16:53:40 +0200 Subject: [PATCH] more streamlined "list" command, but "list " doesn't work --- kiwi_scp/commands/cmd_list.py | 9 ++++----- kiwi_scp/misc.py | 9 +++++---- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/kiwi_scp/commands/cmd_list.py b/kiwi_scp/commands/cmd_list.py index 0918b0c..9b127bf 100644 --- a/kiwi_scp/commands/cmd_list.py +++ b/kiwi_scp/commands/cmd_list.py @@ -1,3 +1,5 @@ +from typing import Tuple + import click from ..instance import Instance, pass_instance @@ -10,12 +12,9 @@ from ..misc import service_command ) @pass_instance @service_command -def cmd(ctx: Instance, project: str, service: str): +def cmd(ctx: Instance, project: str, services: Tuple[str]): """List projects in this instance, services inside a project or service(s) inside a project""" if project is not None: - if service is not None: - print(f"{ctx.get_service(project, service)}") - else: - print(f"services: {ctx.get_services(project)}") + print(ctx.get_services(project, services)) else: print(f"projects: {ctx.config.projects}") diff --git a/kiwi_scp/misc.py b/kiwi_scp/misc.py index c4895f0..dccc434 100644 --- a/kiwi_scp/misc.py +++ b/kiwi_scp/misc.py @@ -27,15 +27,16 @@ _project_arg = click.argument( type=str, ) -_service_arg = click.argument( - "service", - required=False, +_services_arg = click.argument( + "services", + metavar="[SERVICE]...", + nargs=-1, type=str, ) instance_command = _MultiDecorator([]) project_command = _MultiDecorator([_project_arg]) -service_command = _MultiDecorator([_project_arg, _service_arg]) +service_command = _MultiDecorator([_project_arg, _services_arg]) def user_query(description: str, default: Any, cast_to: Type[Any] = str):