diff --git a/changelog.d/20220523_140701_rudyardrichter.md b/changelog.d/20220523_140701_rudyardrichter.md new file mode 100644 index 000000000..8a55bbc29 --- /dev/null +++ b/changelog.d/20220523_140701_rudyardrichter.md @@ -0,0 +1,3 @@ +### Other + +* Increase the maximum width of help output to 80% of the terminal size. diff --git a/src/globus_cli/parsing/commands.py b/src/globus_cli/parsing/commands.py index 07c2cc464..1fbf474b6 100644 --- a/src/globus_cli/parsing/commands.py +++ b/src/globus_cli/parsing/commands.py @@ -8,6 +8,7 @@ import logging import sys +from shutil import get_terminal_size from typing import List import click @@ -51,6 +52,15 @@ def __init__(self, *args, **kwargs): kwargs["help"] = helptext.format( AUTOMATIC_ACTIVATION=self.AUTOMATIC_ACTIVATION_HELPTEXT ) + if "context_settings" not in kwargs: + kwargs["context_settings"] = {} + if "max_content_width" not in kwargs["context_settings"]: + try: + cols = get_terminal_size(fallback=(80, 20)).columns + content_width = cols if cols < 100 else int(0.8 * cols) + kwargs["context_settings"]["max_content_width"] = content_width + except OSError: + pass super().__init__(*args, **kwargs) def invoke(self, ctx):