From e3eba874a29784b00aa9823e7852c6551fa3d01a Mon Sep 17 00:00:00 2001 From: Marc Cataford Date: Sat, 27 Apr 2024 11:48:36 -0400 Subject: [PATCH] feat(client): add success, error, no-op messaging --- spud/cli.py | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/spud/cli.py b/spud/cli.py index 829a8c4..1fba4ac 100644 --- a/spud/cli.py +++ b/spud/cli.py @@ -80,11 +80,26 @@ def print_config(context): @click.command() @click.pass_context def status(context): - response = context.obj["api_client"].get("/status") - data = response.json() + """ + Reports on the status of running services in a tree-like format. + """ + + try: + response = context.obj["api_client"].get("/status") + data = response.json() + except Exception as exc: # pylint: disable=broad-exception-caught + click.secho(f"Failed to get services statuses: {str(exc)}", bold=True, fg="red") + return + + if not data: + click.secho("No running services to report on.", bold=True, fg="yellow") + return for service in data: - click.echo(f"{service['name']}: {service['status']}") + click.echo( + click.style(f"{service['name']}", bold=True, fg="green") + + f": {service['status']}" + ) for container in service["containers"]: click.echo(f" + {container['name']} - {container['status']}")