Skip to content

Only require colorama on Windows #266

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
termcolor
colorama
colorama; sys_platform=='win32'
shtab>=1.3.10
7 changes: 5 additions & 2 deletions tldr.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
from urllib.request import urlopen, Request
from urllib.error import HTTPError, URLError
from termcolor import colored
import colorama # Required for Windows
import shtab

__version__ = "3.3.0"
Expand Down Expand Up @@ -643,6 +642,7 @@ def main() -> None:
parser = create_parser()

options = parser.parse_args()

display_option_length = "long"
if not (options.short_options or options.long_options):
if os.environ.get('TLDR_OPTIONS') == "short":
Expand All @@ -657,7 +657,10 @@ def main() -> None:
display_option_length = "long"
if options.short_options and options.long_options:
display_option_length = "both"
colorama.init(strip=options.color)
if sys.platform == "win32":
import colorama
colorama.init(strip=options.color)

if options.color is False:
os.environ["FORCE_COLOR"] = "true"

Expand Down