class Thor::Shell::Basic

Public Instance Methods

prepare_message(message, *color, paint: true) click to toggle source
# File lib/dnsblim/thor.rb, line 51
def prepare_message(message, *color, paint: true)
  case paint
  when true
    spaces = "  " * padding
    spaces + Paint[message.to_s, *color]
  when false
    spaces = "  " * padding
    spaces + set_color(message.to_s, *color)
  else
    spaces = "  " * padding
    spaces + Paint[message.to_s, *color]
  end

end
print_wrapped(message, options = {}) click to toggle source

@note Override Thor::Shell::Basic.print_wrapped @overload Thor::Shell::Basic.print_wrapped

1. Replace 6 - with 6 spaces
2. Replace 4 - with 4 spaces
3. Replace 2 - with 2 spaces
4. Replace #$ at the beginning of lines
  with '\n'
say(message = "", color = nil, force_new_line = (message.to_s !~ /( |\t)\Z/), paint: true) click to toggle source

Say (print) something to the user. If the sentence ends with a whitespace or tab character, a new line is not appended (print + flush). Otherwise are passed straight to puts (behavior got from Highline).

Example

say(“I know you knew that.”)

# File lib/dnsblim/thor.rb, line 73
def say(message = "", color = nil, force_new_line = (message.to_s !~ /( |\t)\Z/), paint: true)
  buffer = prepare_message(message, *color, paint: paint)
  buffer << "\n" if force_new_line && !message.to_s.end_with?("\n")

  stdout.print(buffer)
  stdout.flush
end