kiwi-scp/kiwi_scp/commands/cmd_list.py

22 lines
609 B
Python
Raw Normal View History

2021-10-21 02:02:38 +00:00
import click
2021-10-28 13:53:32 +00:00
from ..instance import Instance, pass_instance
from ..misc import service_command
2021-10-21 02:02:38 +00:00
2021-10-22 15:52:46 +00:00
@click.command(
"list",
short_help="Inspect a kiwi-scp instance",
)
2021-10-28 13:53:32 +00:00
@pass_instance
2021-10-21 02:02:38 +00:00
@service_command
2021-10-28 13:53:32 +00:00
def cmd(ctx: Instance, project: str, service: str):
2021-10-22 15:52:46 +00:00
"""List projects in this instance, services inside a project or service(s) inside a project"""
2021-10-28 13:53:32 +00:00
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)}")
else:
print(f"projects: {ctx.config.projects}")