more streamlined "list" command, but "list <project>" doesn't work

This commit is contained in:
Jörn-Michael Miehe 2021-10-28 16:53:40 +02:00
parent ed29243b71
commit fc55e9d677
2 changed files with 9 additions and 9 deletions

View file

@ -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}")

View file

@ -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):