From ef593d6cd9c17d8b87368398b4810eb3350bddbc Mon Sep 17 00:00:00 2001 From: ldericher <40151420+ldericher@users.noreply.github.com> Date: Wed, 1 Dec 2021 13:07:35 +0100 Subject: [PATCH] preparation for KiwiCommandType.PROJECTS --- kiwi_scp/commands/cli.py | 1 + kiwi_scp/commands/decorators.py | 23 ++++++++++++++++++++--- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/kiwi_scp/commands/cli.py b/kiwi_scp/commands/cli.py index 755162d..2d01adf 100644 --- a/kiwi_scp/commands/cli.py +++ b/kiwi_scp/commands/cli.py @@ -194,4 +194,5 @@ class KiwiCommand: class KiwiCommandType(Enum): INSTANCE = auto() PROJECT = auto() + PROJECTS = auto() SERVICE = auto() diff --git a/kiwi_scp/commands/decorators.py b/kiwi_scp/commands/decorators.py index 04e470f..61777b1 100644 --- a/kiwi_scp/commands/decorators.py +++ b/kiwi_scp/commands/decorators.py @@ -11,13 +11,27 @@ _pass_instance = click.make_pass_decorator( ) _project_arg = click.argument( + "project_name", + metavar="PROJECT", + required=False, # TODO remove this line when PROJECTS logic is implemented + type=str, +) + +_projects_arg = click.argument( + "project_names", + metavar="[PROJECT]...", + nargs=-1, + type=str, +) + +_services_arg_p = click.argument( "project_name", metavar="[PROJECT]", required=False, type=str, ) -_services_arg = click.argument( +_services_arg_s = click.argument( "service_names", metavar="[SERVICE]...", nargs=-1, @@ -46,9 +60,12 @@ def kiwi_command( if cmd_type is KiwiCommandType.PROJECT: cmd = _project_arg(cmd) + elif cmd_type is KiwiCommandType.PROJECTS: + cmd = _projects_arg(cmd) + elif cmd_type is KiwiCommandType.SERVICE: - cmd = _project_arg(cmd) - cmd = _services_arg(cmd) + cmd = _services_arg_p(cmd) + cmd = _services_arg_s(cmd) return cmd