Coverage for harbor_cli/output/table/commandsummary.py: 100%
19 statements
« prev ^ index » next coverage.py v6.5.0, created at 2023-02-09 12:09 +0100
« prev ^ index » next coverage.py v6.5.0, created at 2023-02-09 12:09 +0100
1from __future__ import annotations
3from typing import Sequence
5from rich.table import Table
7from ...models import CommandSummary
8from ..formatting.builtin import int_str
9from ._utils import get_table
12def commandsummary_table(c: Sequence[CommandSummary]) -> Table:
13 """Display summary of commands in a table."""
14 table = get_table("Results", c)
15 table.add_column("Command")
16 table.add_column("Description")
18 # If we got these commands from a search, we can show a score
19 has_score = any(cmd.score for cmd in c)
20 if has_score:
21 table.add_column("Match", justify="right")
23 for cmd in c:
24 row = [cmd.name, cmd.help]
25 if has_score:
26 row.append(int_str(cmd.score))
27 table.add_row(*row)
28 return table