Skip to content

Commit 30459c3

Browse files
authored
Merge pull request #31 from Stackmasters/display-objects-in-json
Refactor: display units in json instead of table
2 parents 488fa7b + 8353ff3 commit 30459c3

2 files changed

Lines changed: 17 additions & 16 deletions

File tree

cycleops/environments.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import typer
22
from rich import print
3-
from rich.table import Table
43

54
from .client import EnvironmentClient, cycleops_client
65
from .exceptions import NotFound

cycleops/units.py

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import typer
22
from rich import print
3-
from rich.table import Table
43

54
from .client import UnitClient, cycleops_client
65
from .exceptions import NotFound
@@ -18,20 +17,23 @@ def list() -> None:
1817
"""
1918

2019
try:
21-
if all:
22-
units = unit_client.list()
23-
24-
if not units:
25-
raise NotFound("No units available")
26-
27-
table = Table(show_header=True, leading=True)
28-
table.add_column("ID", width=5)
29-
table.add_column("Name", width=30)
30-
31-
for unit in units:
32-
table.add_row(str(unit["id"]), unit["name"])
33-
34-
print(table)
20+
raw_units = unit_client.list()
21+
22+
if not raw_units:
23+
raise NotFound("No units available")
24+
25+
units = [
26+
{
27+
"id": raw_unit.get("id"),
28+
"name": raw_unit.get("name"),
29+
"type_slug": raw_unit.get("type_slug"),
30+
"service_groups_slugs": raw_unit.get("service_groups_slugs"),
31+
}
32+
for raw_unit in raw_units
33+
if raw_unit.get("type_slug") != "system"
34+
]
35+
36+
print(units)
3537
except Exception as error:
3638
display_error_message(error)
3739
raise typer.Exit(code=1)

0 commit comments

Comments
 (0)