Skip to content

Commit

Permalink
improved table
Browse files Browse the repository at this point in the history
  • Loading branch information
soldni committed Oct 19, 2022
1 parent 3323618 commit d958f3a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "springs"
version = "1.7.0"
version = "1.7.1"
description = "A set of utilities to create and manage typed configuration files effectively, built on top of OmegaConf."
authors = [
{name = "Luca Soldaini", email = "[email protected]" }
Expand Down
2 changes: 1 addition & 1 deletion src/springs/commandline.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ def wrap_main_method(
columns=["Resolver Name"],
values=[(r,) for r in sorted(all_resolvers())],
caption=(
"Resolvers use syntax ${resolver_name:'arg1','arg2'}. "
"Resolvers use syntax ${resolver_name:'arg1','arg2'}.\n"
"For more information, visit https://omegaconf.readthedocs.io/"
"en/latest/custom_resolvers.html"
),
Expand Down
5 changes: 4 additions & 1 deletion src/springs/rich_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,11 @@ def print_table(
# repeat colors if we have more columns than colors
colors = colors * (len(columns) // len(colors) + 1)

def _get_longest_row(text: str) -> int:
return max(len(row) for row in text.splitlines())

min_width = min(
max(len(title), len(caption or "")) + 2,
max(_get_longest_row(title), _get_longest_row(caption or "")) + 2,
os.get_terminal_size().columns - 2,
)

Expand Down

0 comments on commit d958f3a

Please sign in to comment.