feat(client): add success, error, no-op messaging
This commit is contained in:
parent
17781b0eb9
commit
e3eba874a2
1 changed files with 18 additions and 3 deletions
21
spud/cli.py
21
spud/cli.py
|
@ -80,11 +80,26 @@ def print_config(context):
|
||||||
@click.command()
|
@click.command()
|
||||||
@click.pass_context
|
@click.pass_context
|
||||||
def status(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:
|
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"]:
|
for container in service["containers"]:
|
||||||
click.echo(f" + {container['name']} - {container['status']}")
|
click.echo(f" + {container['name']} - {container['status']}")
|
||||||
|
|
Reference in a new issue