Skip to content

Commit 3e626ce

Browse files
committed
add table title and caption
1 parent fe75360 commit 3e626ce

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

src/rich_cli/__main__.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -584,7 +584,7 @@ def print_usage() -> None:
584584

585585
elif resource_format == CSV:
586586

587-
renderable = render_csv(resource, head, tail)
587+
renderable = render_csv(resource, head, tail, title, caption)
588588

589589
else:
590590
if not resource:
@@ -678,6 +678,7 @@ def print_usage() -> None:
678678
renderable,
679679
width=None if max_width <= 0 else max_width,
680680
soft_wrap=soft,
681+
justify=justify,
681682
)
682683
except Exception as error:
683684
on_error("failed to print resource", error)
@@ -690,7 +691,11 @@ def print_usage() -> None:
690691

691692

692693
def render_csv(
693-
resource: str, head: Optional[int] = None, tail: Optional[int] = None
694+
resource: str,
695+
head: Optional[int] = None,
696+
tail: Optional[int] = None,
697+
title: Optional[str] = None,
698+
caption: Optional[str] = None,
694699
) -> RenderableType:
695700
"""Render resource as CSV.
696701
@@ -724,6 +729,9 @@ def render_csv(
724729
show_header=has_header,
725730
box=box.HEAVY_HEAD if has_header else box.SQUARE,
726731
border_style="blue",
732+
title=title,
733+
caption=caption,
734+
caption_justify="right",
727735
)
728736
rows = iter(reader)
729737
if has_header:

0 commit comments

Comments
 (0)