Print component list as a formatted table.
(components: list[dict[str, Any]])
| 496 | |
| 497 | |
| 498 | def print_components_table(components: list[dict[str, Any]]) -> None: |
| 499 | """Print component list as a formatted table.""" |
| 500 | if not components: |
| 501 | print_line("No components found") |
| 502 | return |
| 503 | |
| 504 | if console.no_color: |
| 505 | headers = ["Type", "ID"] |
| 506 | rows: list[list[str]] = [] |
| 507 | for comp in components: |
| 508 | comp_type = comp.get("typeName", comp.get("type", "Unknown")) |
| 509 | instance_id = str(comp.get("instanceID", "")) |
| 510 | rows.append([comp_type, instance_id]) |
| 511 | _print_plain_table(headers, rows, f"Components ({len(components)})") |
| 512 | return |
| 513 | |
| 514 | table = Table(title=f"Components ({len(components)})") |
| 515 | table.add_column("Type", style="cyan") |
| 516 | table.add_column("ID", style="dim", justify="right") |
| 517 | |
| 518 | for comp in components: |
| 519 | comp_type = escape(comp.get("typeName", comp.get("type", "Unknown"))) |
| 520 | instance_id = str(comp.get("instanceID", "")) |
| 521 | |
| 522 | table.add_row(comp_type, instance_id) |
| 523 | |
| 524 | console.print(table) |
| 525 | |
| 526 | |
| 527 | def _format_duration(duration: Any) -> str: |
no test coverage detected