Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion src/rich_cli/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,11 @@ class OptionHighlighter(RegexHighlighter):
is_flag=True,
help="Enable indentation guides in syntax highlighting",
)
@click.option(
"--show-lines",
is_flag=True,
help="Show lines between rows in CSV tables.",
)
@click.option(
"--lexer",
"-x",
Expand Down Expand Up @@ -435,6 +440,7 @@ def main(
theme: str = "",
line_numbers: bool = False,
guides: bool = False,
show_lines: bool = False,
lexer: str = "",
hyperlinks: bool = False,
force_terminal: bool = False,
Expand Down Expand Up @@ -607,7 +613,7 @@ def print_usage() -> None:

elif resource_format == CSV:

renderable = render_csv(resource, head, tail, title, caption)
renderable = render_csv(resource, head, tail, title, caption, show_lines)

elif resource_format == IPYNB:

Expand Down Expand Up @@ -739,11 +745,17 @@ def render_csv(
tail: Optional[int] = None,
title: Optional[str] = None,
caption: Optional[str] = None,
show_lines: bool = False,
) -> RenderableType:
"""Render resource as CSV.

Args:
resource (str): Resource string.
head (Optional[int]): Display first LINES of the file.
tail (Optional[int]): Display last LINES of the file.
title (Optional[str]): Title for the table.
caption (Optional[str]): Caption for the table.
show_lines (bool): Show lines between rows.

Returns:
RenderableType: Table renderable.
Expand Down Expand Up @@ -782,6 +794,7 @@ def render_csv(
title=title,
caption=caption,
caption_justify="right",
show_lines=show_lines,
)
rows = iter(reader)
if has_header:
Expand Down