Skip to content

Commit d25dbfe

Browse files
committed
Add --show-lines option for CSV tables
- Added --show-lines CLI flag to control line display between CSV rows - Updated render_csv function to accept show_lines parameter
1 parent ccaef38 commit d25dbfe

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/rich_cli/__main__.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,11 @@ class OptionHighlighter(RegexHighlighter):
363363
is_flag=True,
364364
help="Enable indentation guides in syntax highlighting",
365365
)
366+
@click.option(
367+
"--show-lines",
368+
is_flag=True,
369+
help="Show lines between rows in CSV tables.",
370+
)
366371
@click.option(
367372
"--lexer",
368373
"-x",
@@ -435,6 +440,7 @@ def main(
435440
theme: str = "",
436441
line_numbers: bool = False,
437442
guides: bool = False,
443+
show_lines: bool = False,
438444
lexer: str = "",
439445
hyperlinks: bool = False,
440446
force_terminal: bool = False,
@@ -607,7 +613,7 @@ def print_usage() -> None:
607613

608614
elif resource_format == CSV:
609615

610-
renderable = render_csv(resource, head, tail, title, caption)
616+
renderable = render_csv(resource, head, tail, title, caption, show_lines)
611617

612618
elif resource_format == IPYNB:
613619

@@ -739,11 +745,17 @@ def render_csv(
739745
tail: Optional[int] = None,
740746
title: Optional[str] = None,
741747
caption: Optional[str] = None,
748+
show_lines: bool = False,
742749
) -> RenderableType:
743750
"""Render resource as CSV.
744751
745752
Args:
746753
resource (str): Resource string.
754+
head (Optional[int]): Display first LINES of the file.
755+
tail (Optional[int]): Display last LINES of the file.
756+
title (Optional[str]): Title for the table.
757+
caption (Optional[str]): Caption for the table.
758+
show_lines (bool): Show lines between rows.
747759
748760
Returns:
749761
RenderableType: Table renderable.
@@ -782,6 +794,7 @@ def render_csv(
782794
title=title,
783795
caption=caption,
784796
caption_justify="right",
797+
show_lines=show_lines,
785798
)
786799
rows = iter(reader)
787800
if has_header:

0 commit comments

Comments
 (0)