Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Increase output width of all commands #643

Merged
merged 1 commit into from
May 23, 2022
Merged
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions changelog.d/20220523_140701_rudyardrichter.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
### Other

* Increase the maximum width of help output to 80% of the terminal size.
10 changes: 10 additions & 0 deletions src/globus_cli/parsing/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import logging
import sys
from shutil import get_terminal_size
from typing import List

import click
Expand Down Expand Up @@ -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):
Expand Down