Skip to content

Commit

Permalink
feat: make CorgyHelpFormatter.max_help_position adaptive
Browse files Browse the repository at this point in the history
  • Loading branch information
jayanthkoushik committed Dec 5, 2021
1 parent 6c76be8 commit 543bca8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
5 changes: 3 additions & 2 deletions corgy/_helpfmt.py
Expand Up @@ -150,7 +150,8 @@ class CorgyHelpFormatter(HelpFormatter, metaclass=_CorgyHelpFormatterMeta):
default), the current terminal width is used.
* `max_help_position`: How far to the right (from the start), the help string can
start from. If `None`, there is no limit. The default is `40`.
start from. If `None`, there is no limit. The default is to use half the current
terminal width.
* `marker_extras_<begin/end>`: The strings used to enclose the extra help text
(choices, default values etc.). The defaults are `(` and `)`.
Expand Down Expand Up @@ -202,7 +203,7 @@ def __corgy_fmt_choice__(choice):
color_options = "BOLD"

output_width: Optional[int] = None
max_help_position: Optional[int] = 40
max_help_position: Optional[int] = shutil.get_terminal_size().columns // 2

marker_extras_begin = "("
marker_extras_end = ")"
Expand Down
3 changes: 2 additions & 1 deletion docs/corgy.md
Expand Up @@ -386,7 +386,8 @@ default), the current terminal width is used.


* `max_help_position`: How far to the right (from the start), the help string can
start from. If `None`, there is no limit. The default is `40`.
start from. If `None`, there is no limit. The default is to use half the current
terminal width.


* `marker_extras_<begin/end>`: The strings used to enclose the extra help text
Expand Down

0 comments on commit 543bca8

Please sign in to comment.