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 HTML
color to black.
Set the terminal's foreground HTML
color to blue.
The start of an HTML
bold sequence.
Set the terminal's foreground HTML
color to cyan.
Set the terminal's foreground HTML
color to green.
Set the terminal's foreground HTML
color to magenta.
Set the terminal's background HTML
color to black.
Set the terminal's background HTML
color to blue.
Set the terminal's background HTML
color to cyan.
Set the terminal's background HTML
color to green.
Set the terminal's background HTML
color to magenta.
Set the terminal's background HTML
color to red.
Set the terminal's background HTML
color to white.
Set the terminal's background HTML
color to yellow.
Set the terminal's foreground HTML
color to red.
Set the terminal's foreground HTML
color to white.
Set the terminal's foreground HTML
color to yellow.
Ask something to the user and receives a response.
ask(“What is your name?”)
TODO: Implement ask
for Bundler::Thor::Shell::HTML
# File bundler/vendor/thor/lib/thor/shell/html.rb, line 70 def ask(statement, color = nil) raise NotImplementedError, "Implement #ask for Bundler::Thor::Shell::HTML" end
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.
# File bundler/vendor/thor/lib/thor/shell/html.rb, line 51 def set_color(string, *colors) if colors.all? { |color| color.is_a?(Symbol) || color.is_a?(String) } html_colors = colors.map { |color| lookup_color(color) } "<span style=\"#{html_colors.join('; ')};\">#{string}</span>" else color, bold = colors html_color = self.class.const_get(color.to_s.upcase) if color.is_a?(Symbol) styles = [html_color] styles << BOLD if bold "<span style=\"#{styles.join('; ')};\">#{string}</span>" end end