Skip to content

Commit

Permalink
cli: request terminal size in an appropriate way.
Browse files Browse the repository at this point in the history
  • Loading branch information
whitequark committed Jul 28, 2020
1 parent 169456e commit 6756333
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion software/glasgow/cli.py
Expand Up @@ -34,7 +34,13 @@

class TextHelpFormatter(argparse.HelpFormatter):
def __init__(self, prog):
columns, rows = os.get_terminal_size(0)
if "COLUMNS" in os.environ:
columns = int(os.environ["COLUMNS"])
else:
try:
columns, _ = os.get_terminal_size(sys.stderr.fileno())
except OSError:
columns = 80
super().__init__(prog, width=columns, max_help_position=28)

def _fill_text(self, text, width, indent):
Expand Down

0 comments on commit 6756333

Please sign in to comment.