Skip to content

Commit 1cf5d47

Browse files
committed
feat: apply coloring to the warning message
Signed-off-by: Dharun Krishna K B <[email protected]>
1 parent 7111bc7 commit 1cf5d47

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

tldr.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -670,15 +670,20 @@ def main() -> None:
670670

671671
options = parser.parse_args()
672672

673+
if sys.platform == "win32":
674+
import colorama
675+
colorama.init(strip=options.color)
676+
673677
if options.platform is None:
674678
platform_env = os.environ.get('TLDR_PLATFORM', '').strip().lower()
675679
if platform_env in OS_DIRECTORIES:
676680
options.platform = [platform_env]
677681
elif platform_env:
678-
print(
679-
f"Warning: '{platform_env}' is not a supported TLDR_PLATFORM env value."
682+
warning_msg = (
683+
f"Warning: '{platform_env}' is not a supported TLDR_PLATFORM environment value."
680684
"\nFalling back to auto-detection."
681685
)
686+
print(colored(warning_msg, 'yellow'))
682687

683688
display_option_length = "long"
684689
if os.environ.get('TLDR_OPTIONS') == "short":
@@ -694,10 +699,6 @@ def main() -> None:
694699
if options.short_options and options.long_options:
695700
display_option_length = "both"
696701

697-
if sys.platform == "win32":
698-
import colorama
699-
colorama.init(strip=options.color)
700-
701702
if options.color is False:
702703
os.environ["FORCE_COLOR"] = "true"
703704

0 commit comments

Comments
 (0)