Skip to content

Commit e732d1a

Browse files
authored
Restore default value of Colorize.enabled. Add Colorize.on_tty_only! (#4271)
Amend #4075 Fix docs
1 parent c4bbb59 commit e732d1a

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/colorize.cr

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ module Colorize
8080
# If this value is `true`, `Colorize::Object` is enabled by default.
8181
# But if this value is `false`, `Colorize::Object` is disabled.
8282
#
83-
# This defaule value is `true` only if both of `STDOUT.tty?` and `STDERR.tty?` are `true`.
83+
# The default value is `true`.
8484
#
8585
# ```
8686
# Colorize.enabled = true
@@ -89,7 +89,12 @@ module Colorize
8989
# Colorize.enabled = false
9090
# "hello".colorize.red.to_s # => "hello"
9191
# ```
92-
class_property? enabled : Bool = STDOUT.tty? && STDERR.tty?
92+
class_property? enabled : Bool = true
93+
94+
# Make `Colorize.enabled` `true` if and only if both of `STDOUT.tty?` and `STDERR.tty?` are `true`.
95+
def self.on_tty_only!
96+
self.enabled = STDOUT.tty? && STDERR.tty?
97+
end
9398
end
9499

95100
def with_color

0 commit comments

Comments
 (0)