Module: Swift::Playground::CLI::UI

Extended by:
SingleForwardable
Defined in:
lib/swift/playground/cli/ui.rb

Class Method Summary collapse

Class Method Details

.debug(message = nil, &block) ⇒ Object



59
60
61
62
63
64
65
66
# File 'lib/swift/playground/cli/ui.rb', line 59

def debug(message = nil, &block)
  return if silence

  if show_debug
    message = formatted_log_message(message, &block)
    stderr.puts blue(message)
  end
end

.error(message = nil, exception = nil) ⇒ Object



47
48
49
50
51
52
53
54
55
56
57
# File 'lib/swift/playground/cli/ui.rb', line 47

def error(message = nil, exception = nil)
  return if silence

  stderr.puts red(message)
  if exception && show_debug
    exception_details = ["Handled <#{exception.class}>:",
                         exception.message,
                         *exception.backtrace]
    stderr.puts red("\n" + exception_details.join("\n") + "\n")
  end
end

.info(message = nil, &block) ⇒ Object



68
69
70
71
72
73
74
75
# File 'lib/swift/playground/cli/ui.rb', line 68

def info(message = nil, &block)
  return if silence

  if show_debug
    message = formatted_log_message(message, &block)
    stderr.puts cyan(message)
  end
end

.say(message = "\n") ⇒ Object



41
42
43
44
45
# File 'lib/swift/playground/cli/ui.rb', line 41

def say(message = "\n")
  return if silence

  terminal.say message
end