terminal.py
python
sha256:6ed6b11aceb96bef850842a7aaac54c04843fa9fba5d1200e4bc3845e12d4142
docs: add muse-tag-guide mist (complete idiomatic guide wit…
Sonnet 4.6
19 days ago
| 1 | """Terminal output helpers shared across CLI commands. |
| 2 | |
| 3 | Provides colour detection that respects ``NO_COLOR`` (https://no-color.org/), |
| 4 | ``TERM=dumb``, and the ``sys.stdout.isatty()`` check, so raw ANSI never leaks |
| 5 | into pipes or logs. |
| 6 | """ |
| 7 | |
| 8 | import os |
| 9 | import sys |
| 10 | |
| 11 | def use_color() -> bool: |
| 12 | """Return ``True`` only when colour output is appropriate. |
| 13 | |
| 14 | Respects ``NO_COLOR`` (https://no-color.org/), ``TERM=dumb``, and the |
| 15 | ``sys.stdout.isatty()`` check so raw ANSI never leaks into pipes or logs. |
| 16 | """ |
| 17 | if os.environ.get("NO_COLOR") or os.environ.get("TERM") == "dumb": |
| 18 | return False |
| 19 | return sys.stdout.isatty() |
File History
1 commit
sha256:6ed6b11aceb96bef850842a7aaac54c04843fa9fba5d1200e4bc3845e12d4142
docs: add muse-tag-guide mist (complete idiomatic guide wit…
Sonnet 4.6
19 days ago