Skip to content

Commit ce05f57

Browse files
authored
Merge pull request #69 from dmerejkowsky/fix-66
Fix regression on non-Windows platforms
2 parents 2119a6b + 749efca commit ce05f57

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

cli_ui/__init__.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,11 @@
3838
_ENABLE_XTERM_TITLE = None
3939

4040

41-
colorama.init()
41+
if os.name == "nt":
42+
# On Windows using `isatty()` does *not* work reliably,
43+
# so we always setup colorama.
44+
# See colors_enabled() for details
45+
colorama.init()
4246

4347

4448
# Tokens can be strings, or Color, UnicodeSequence or Symbol instances,
@@ -655,8 +659,10 @@ def main_demo() -> None:
655659

656660
def main() -> None:
657661
parser = argparse.ArgumentParser()
662+
parser.add_argument("--color", choices=["always", "never", "auto"])
658663
parser.add_argument("action", choices=["test_colors", "demo"])
659664
args = parser.parse_args()
665+
setup(color=args.color)
660666
if args.action == "demo":
661667
main_demo()
662668
elif args.action == "test_colors":

docs/changelog.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ v0.14.1
55
+++++++
66

77
* Development branch is now called ``main``.
8+
* Fix #66 - only call ``colorama.init()`` on Windows.
89

910
v0.14.0 (2021-04-20)
1011
++++++++++++++++++++

0 commit comments

Comments
 (0)