Skip to content

Commit 1f6b04a

Browse files
committed
Properly handle CI environment terminals
Fixes #1 Signed-off-by: Pedro Algarvio <[email protected]>
1 parent a58d600 commit 1f6b04a

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/ptscripts/parser.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import argparse
77
import inspect
88
import logging
9+
import os
910
import pathlib
1011
import sys
1112
import typing
@@ -70,14 +71,20 @@ def __init__(self, parser: Parser):
7071
"exit-failure": "bold red",
7172
}
7273
)
73-
self.console = Console(stderr=True, theme=theme)
74+
console_kwargs = {
75+
"theme": theme,
76+
}
77+
if os.environ.get("CI"):
78+
console_kwargs["force_terminal"] = True
79+
console_kwargs["force_interactive"] = False
80+
self.console = Console(sterr=True, **console_kwargs)
81+
self.console_stdout = Console(**console_kwargs)
7482

7583
def print(self, *args, **kwargs):
7684
"""
7785
Print to stdout.
7886
"""
79-
with self.console.screen(stderr=False) as console:
80-
console.print(*args, **kwargs)
87+
self.console_stdout.print(*args, **kwargs)
8188

8289
def debug(self, *args):
8390
"""

0 commit comments

Comments
 (0)