Inherit from Bundler::Thor::Shell::Basic and add #set_color behavior. Check Bundler::Thor::Shell::Basic to see all available methods.
Set the terminal’s foreground ANSI color to black.
Set the terminal’s foreground ANSI color to blue.
The start of an ANSI bold sequence.
Embed in a String to clear all previous ANSI sequences.
Set the terminal’s foreground ANSI color to cyan.
Set the terminal’s foreground ANSI color to green.
Set the terminal’s foreground ANSI color to magenta.
Set the terminal’s background ANSI color to black.
Set the terminal’s background ANSI color to blue.
Set the terminal’s background ANSI color to cyan.
Set the terminal’s background ANSI color to green.
Set the terminal’s background ANSI color to magenta.
Set the terminal’s background ANSI color to red.
Set the terminal’s background ANSI color to white.
Set the terminal’s background ANSI color to yellow.
Set the terminal’s foreground ANSI color to red.
Set the terminal’s foreground ANSI color to white.
Set the terminal’s foreground ANSI color to yellow.
Set color by using a string or one of the defined constants. If a third option is set to true, it also adds bold to the string. This is based on Highline implementation and it automatically appends CLEAR to the end of the returned String.
Pass foreground, background and bold options to this method as symbols.
Example:
set_color "Hi!", :red, :on_white, :bold
The available colors are:
:bold :black :red :green :yellow :blue :magenta :cyan :white :on_black :on_red :on_green :on_yellow :on_blue :on_magenta :on_cyan :on_white
# File bundler/vendor/thor/lib/thor/shell/color.rb, line 79 def set_color(string, *colors) if colors.compact.empty? || !can_display_colors? string elsif colors.all? { |color| color.is_a?(Symbol) || color.is_a?(String) } ansi_colors = colors.map { |color| lookup_color(color) } "#{ansi_colors.join}#{string}#{CLEAR}" else # The old API was `set_color(color, bold=boolean)`. We # continue to support the old API because you should never # break old APIs unnecessarily :P foreground, bold = colors foreground = self.class.const_get(foreground.to_s.upcase) if foreground.is_a?(Symbol) bold = bold ? BOLD : "" "#{bold}#{foreground}#{string}#{CLEAR}" end end
# File bundler/vendor/thor/lib/thor/shell/color.rb, line 107 def are_colors_disabled? !ENV['NO_COLOR'].nil? end