toolforge-components-cli 0.0.3__py3-none-any.whl → 0.0.5__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -6,9 +6,12 @@ import logging
6
6
  import os
7
7
  import subprocess
8
8
  import sys
9
+ from textwrap import indent
10
+ from typing import Any
9
11
 
10
12
  import click
11
13
  import yaml
14
+ from tabulate import tabulate
12
15
  from toolforge_weld.errors import (
13
16
  ToolforgeError,
14
17
  ToolforgeUserError,
@@ -88,12 +91,29 @@ def _display_deployment(deployment_data: dict, as_json: bool, prefix: str = "")
88
91
  else:
89
92
  if prefix:
90
93
  click.echo(prefix)
91
- click.echo(f"Deployment ID: {deployment_data.get('deploy_id')}")
92
- click.echo(f"Created: {deployment_data.get('creation_time')}")
94
+ click.echo(
95
+ click.style("Deployment ID: ", bold=True) + deployment_data["deploy_id"]
96
+ )
97
+ click.echo(
98
+ click.style("Created: ", bold=True) + deployment_data["creation_time"]
99
+ )
100
+ click.echo(
101
+ click.style("Status: ", bold=True)
102
+ + _format_status(deployment_data.get("status", "unknown"))
103
+ )
104
+ click.echo(
105
+ click.style("Long status: ", bold=True)
106
+ + "\n"
107
+ + indent(text=deployment_data.get("long_status", "unknown"), prefix=" ")
108
+ )
93
109
  if deployment_data.get("builds"):
94
- click.echo("\nBuilds:" if not prefix else "Builds:")
110
+ click.echo(
111
+ "\n" + click.style("Builds:" if not prefix else "Builds:", bold=True)
112
+ )
95
113
  for component, build in deployment_data["builds"].items():
96
- click.echo(f" {component}: {build.get('build_id')}")
114
+ click.echo(
115
+ f" {component}({_format_status(build['build_status'])}): {build['build_id']}"
116
+ )
97
117
 
98
118
 
99
119
  @click.version_option(prog_name="Toolforge Components CLI")
@@ -349,7 +369,35 @@ def deployment_create(ctx, as_json: bool) -> None:
349
369
  if deployment_data.get("builds"):
350
370
  click.echo("\nBuilds:")
351
371
  for component, build in deployment_data["builds"].items():
352
- click.echo(f" {component}: {build.get('build_id')}")
372
+ click.echo(
373
+ f" {component}({_format_status(build['build_status'])}): {build['build_id']}"
374
+ )
375
+
376
+
377
+ def _format_headers(headers: list[str]) -> list[str]:
378
+ return [click.style(item, bold=True) for item in headers]
379
+
380
+
381
+ def _format_builds(builds: dict[str, dict[str, Any]]) -> str:
382
+ builds_strings: list[str] = []
383
+ for component_name, build_info in builds.items():
384
+ builds_strings.append(
385
+ f"{component_name}({_format_status(build_info['build_status'])}): {build_info['build_id']}"
386
+ )
387
+ return "\n".join(builds_strings)
388
+
389
+
390
+ def _format_status(status: str) -> str:
391
+ fg_color = "yellow"
392
+
393
+ if status in ("running", "pending"):
394
+ fg_color = "white"
395
+ elif status == "failed":
396
+ fg_color = "red"
397
+ elif status == "successful":
398
+ fg_color = "green"
399
+
400
+ return click.style(status, fg=fg_color)
353
401
 
354
402
 
355
403
  @deployment.command(name="list", help="List all deployments.")
@@ -371,13 +419,21 @@ def deployment_list(ctx, as_json: bool) -> None:
371
419
  return
372
420
 
373
421
  deployments = response.get("data", {}).get("deployments", [])
374
- for deployment in deployments:
375
- click.echo(f"\nDeployment ID: {deployment.get('deploy_id')}")
376
- click.echo(f"Created: {deployment.get('creation_time')}")
377
- if deployment.get("builds"):
378
- click.echo("Builds:")
379
- for component, build in deployment["builds"].items():
380
- click.echo(f" {component}: {build.get('build_id')}")
422
+ formatted_deployments = [
423
+ [
424
+ deployment["deploy_id"],
425
+ deployment["creation_time"],
426
+ _format_status(deployment.get("status", "unknown")),
427
+ _format_builds(deployment.get("builds", [])),
428
+ ]
429
+ for deployment in deployments
430
+ ]
431
+ click.echo(
432
+ tabulate(
433
+ formatted_deployments,
434
+ headers=_format_headers(["ID", "Creation time", "Status", "Builds"]),
435
+ )
436
+ )
381
437
 
382
438
 
383
439
  @deployment.command(name="show", help="Show details of a specific deployment.")
@@ -430,6 +486,7 @@ def deployment_delete(
430
486
 
431
487
 
432
488
  def main() -> int:
489
+ debug = False
433
490
  try:
434
491
  args = sys.argv[1:]
435
492
  debug = "-d" in args or "--debug" in args
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: toolforge-components-cli
3
- Version: 0.0.3
3
+ Version: 0.0.5
4
4
  Summary: Toolforge components client
5
5
  License: GPLv3
6
6
  Author: Slavina Stefanova
@@ -0,0 +1,9 @@
1
+ toolforge_components_cli/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
+ toolforge_components_cli/cli.py,sha256=cV1ktOizDX6mg3heEonNsBnIyjja4zo3sHmofswVPYs,15698
3
+ toolforge_components_cli/components.py,sha256=ISGD-ahjp6mndIgCxU6V98X0Xcb7abJuLjc_Rk4CjZU,3128
4
+ toolforge_components_cli/config.py,sha256=wT8-kciiOIYcjoB9EELjc2FQARooQSBQlZv3elvMH2k,730
5
+ toolforge_components_cli-0.0.5.dist-info/LICENSE,sha256=4cCtcomD2KVzNeUs8QZPGv_R1FQXPYzr0-2LSnK0hwQ,35121
6
+ toolforge_components_cli-0.0.5.dist-info/METADATA,sha256=x4l3O7AzcVQ8bPq1yPbHcoUot93lntxl86LIK402WlQ,1523
7
+ toolforge_components_cli-0.0.5.dist-info/WHEEL,sha256=XbeZDeTWKc1w7CSIyre5aMDU_-PohRwTQceYnisIYYY,88
8
+ toolforge_components_cli-0.0.5.dist-info/entry_points.txt,sha256=D1g7NaMicWBsSJmJXBVU9eUnVfg45d_o4Io7LQe-SWE,74
9
+ toolforge_components_cli-0.0.5.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: poetry-core 2.0.1
2
+ Generator: poetry-core 2.1.1
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
@@ -1,9 +0,0 @@
1
- toolforge_components_cli/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- toolforge_components_cli/cli.py,sha256=I1q8ulVDE3fw4lyR8toLLXGlv0EOXnU02lEFd6WW8so,14140
3
- toolforge_components_cli/components.py,sha256=ISGD-ahjp6mndIgCxU6V98X0Xcb7abJuLjc_Rk4CjZU,3128
4
- toolforge_components_cli/config.py,sha256=wT8-kciiOIYcjoB9EELjc2FQARooQSBQlZv3elvMH2k,730
5
- toolforge_components_cli-0.0.3.dist-info/LICENSE,sha256=4cCtcomD2KVzNeUs8QZPGv_R1FQXPYzr0-2LSnK0hwQ,35121
6
- toolforge_components_cli-0.0.3.dist-info/METADATA,sha256=DDhbjyF2SFJ9WKG-HHWunSAI2ceQ43XJGiNsZPg-Mg8,1523
7
- toolforge_components_cli-0.0.3.dist-info/WHEEL,sha256=IYZQI976HJqqOpQU6PHkJ8fb3tMNBFjg-Cn-pwAbaFM,88
8
- toolforge_components_cli-0.0.3.dist-info/entry_points.txt,sha256=D1g7NaMicWBsSJmJXBVU9eUnVfg45d_o4Io7LQe-SWE,74
9
- toolforge_components_cli-0.0.3.dist-info/RECORD,,