lib/spoom/cli/helper.rb in spoom-1.1.4 vs lib/spoom/cli/helper.rb in spoom-1.1.5
- old
+ new
@@ -8,12 +8,13 @@
module Spoom
module Cli
module Helper
extend T::Sig
extend T::Helpers
- include Thor::Shell
+ include Colorize
+
requires_ancestor { Thor }
# Print `message` on `$stdout`
sig { params(message: String).void }
def say(message)
@@ -83,11 +84,11 @@
end
# Colors
# Color used to highlight expressions in backticks
- HIGHLIGHT_COLOR = :blue
+ HIGHLIGHT_COLOR = T.let(Spoom::Color::BLUE, Spoom::Color)
# Is the `--color` option true?
sig { returns(T::Boolean) }
def color?
options[:color]
@@ -115,38 +116,38 @@
end
res.string
end
# Colorize a string if `color?`
- sig { params(string: String, color: Symbol).returns(String) }
- def colorize(string, color)
+ sig { params(string: String, color: Color).returns(String) }
+ def colorize(string, *color)
return string unless color?
- string.colorize(color)
+ T.unsafe(self).set_color(string, *color)
end
sig { params(string: String).returns(String) }
def blue(string)
- colorize(string, :blue)
+ colorize(string, Color::BLUE)
end
sig { params(string: String).returns(String) }
def gray(string)
- colorize(string, :light_black)
+ colorize(string, Color::LIGHT_BLACK)
end
sig { params(string: String).returns(String) }
def green(string)
- colorize(string, :green)
+ colorize(string, Color::GREEN)
end
sig { params(string: String).returns(String) }
def red(string)
- colorize(string, :red)
+ colorize(string, Color::RED)
end
sig { params(string: String).returns(String) }
def yellow(string)
- colorize(string, :yellow)
+ colorize(string, Color::YELLOW)
end
end
end
end