Skip to content

Commit 1a565b0

Browse files
hukkinkbdharun
andauthored
Only require colorama on Windows (#266)
Co-authored-by: K.B.Dharun Krishna <[email protected]>
1 parent 1d36280 commit 1a565b0

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

Diff for: requirements.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
termcolor
2-
colorama
2+
colorama; sys_platform=='win32'
33
shtab>=1.3.10

Diff for: tldr.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
from urllib.request import urlopen, Request
1616
from urllib.error import HTTPError, URLError
1717
from termcolor import colored
18-
import colorama # Required for Windows
1918
import shtab
2019

2120
__version__ = "3.3.0"
@@ -643,6 +642,7 @@ def main() -> None:
643642
parser = create_parser()
644643

645644
options = parser.parse_args()
645+
646646
display_option_length = "long"
647647
if not (options.short_options or options.long_options):
648648
if os.environ.get('TLDR_OPTIONS') == "short":
@@ -657,7 +657,10 @@ def main() -> None:
657657
display_option_length = "long"
658658
if options.short_options and options.long_options:
659659
display_option_length = "both"
660-
colorama.init(strip=options.color)
660+
if sys.platform == "win32":
661+
import colorama
662+
colorama.init(strip=options.color)
663+
661664
if options.color is False:
662665
os.environ["FORCE_COLOR"] = "true"
663666

0 commit comments

Comments
 (0)