Skip to content

Commit

Permalink
fix: disable colors in pdm help on legacy terminals of windows (#2684)
Browse files Browse the repository at this point in the history
  • Loading branch information
frostming authored Mar 13, 2024
1 parent 9e712c2 commit 46d0064
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions news/2678.bugfix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix the issue that ANSI codes are shown in the output of `pdm --help` on Windows.
2 changes: 2 additions & 0 deletions src/pdm/termui.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ def style(text: str, *args: str, style: str | None = None, **kwargs: Any) -> str
:param style: rich style to apply to whole string
:return: string containing ansi codes
"""
if _console.legacy_windows or not _console.is_terminal: # pragma: no cover
return text
with _console.capture() as capture:
_console.print(text, *args, end="", style=style, **kwargs)
return capture.get()
Expand Down

0 comments on commit 46d0064

Please sign in to comment.