projg2 / flaggie

A smart CLI mangler for package.* files
MIT License
48 stars 7 forks source link

Flaggie crashes when tty is not initialized #38

Closed edannenberg closed 1 year ago

edannenberg commented 1 year ago

Hello,

running Flaggie in a docker container fails with:

Traceback (most recent call last):
  File "/usr/lib/python-exec/python3.10/flaggie", line 8, in <module>
    sys.exit(entry_point())
  File "/usr/lib/python3.10/site-packages/flaggie/__main__.py", line 353, in entry_point
    sys.exit(main(*sys.argv))
  File "/usr/lib/python3.10/site-packages/flaggie/__main__.py", line 191, in main
    epilog="\n".join(textwrap.fill(x,
  File "/usr/lib/python3.10/site-packages/flaggie/__main__.py", line 191, in <genexpr>
    epilog="\n".join(textwrap.fill(x,
  File "/usr/lib/python3.10/textwrap.py", line 399, in fill
    return w.fill(text)
  File "/usr/lib/python3.10/textwrap.py", line 371, in fill
    return "\n".join(self.wrap(text))
  File "/usr/lib/python3.10/textwrap.py", line 362, in wrap
    return self._wrap_chunks(chunks)
  File "/usr/lib/python3.10/textwrap.py", line 256, in _wrap_chunks
    raise ValueError("invalid width %r (must be > 0)" % self.width)
ValueError: invalid width -2 (must be > 0)

I assumed this was due to a missing tty but the tty binary and docker inspect both say that is not the problem. Digging deeper stty -a gave me the root of the problem:

speed 38400 baud; rows 0; columns 0; line = 0;

Running stty rows 50 cols 80 before flaggie fixes the issues. Could this possibly handled in flaggie gracefully? Thanks!

mgorny commented 1 year ago

Thank you for the report. I'll try to fix it and release a version with the fix today.

edannenberg commented 1 year ago

That did the trick, thanks for the swift fix!

mgorny commented 1 year ago

Thanks!