module Commandline::Output

Public Instance Methods

error(text) click to toggle source
# File lib/utils/commandline/output.rb, line 15
def error(text)
  prefix(text, '[ERROR] ').red
end
ok(text) click to toggle source
# File lib/utils/commandline/output.rb, line 11
def ok(text)
  prefix(text, '[OK] ').green
end
output() click to toggle source
# File lib/utils/commandline/output.rb, line 3
def output
  @output ||= STDOUT
end
prefix(text, prefix) click to toggle source
# File lib/utils/commandline/output.rb, line 19
def prefix(text, prefix)
  lines = text.lines
  message = "#{prefix}#{lines[0].strip}\n"
  lines[1..-1].each_with_index do |line, index|
    line = line.strip.chomp
    line = line.rjust(line.length + prefix.size)

    message << (index.zero? ? line : line.prepend("\n"))
  end
  message
end
say(msg) click to toggle source
# File lib/utils/commandline/output.rb, line 7
def say(msg)
  output.puts msg unless ENV['SILENT']
end