Trim line when printing table, simplify code

This commit is contained in:
Ivan Habunek 2024-08-30 13:39:41 +02:00
parent 75423c7671
commit 8c68132ddb
No known key found for this signature in database
GPG Key ID: 01DB3DD0D824504C

View File

@ -46,11 +46,8 @@ def print_table(headers: List[str], data: List[List[str]]):
underlines = ["-" * width for width in widths]
def print_row(row: List[str]):
for idx, cell in enumerate(row):
width = widths[idx]
click.echo(ljust(cell, width), nl=False)
click.echo(" ", nl=False)
click.echo()
parts = (ljust(cell, widths[idx]) for idx, cell in enumerate(row))
click.echo(" ".join(parts).strip())
print_row(headers)
print_row(underlines)