Module: PiotrbCliUtils::Util

Defined in:
lib/piotrb_cli_utils/util.rb

Instance Method Summary collapse

Instance Method Details

#fail_with(*messages, code: 1) ⇒ Object



5
6
7
8
9
10
# File 'lib/piotrb_cli_utils/util.rb', line 5

def fail_with(*messages, code: 1)
  messages.each do |message|
    warn(Paint[message, :red])
  end
  exit code
end

#log(message, depth: 0, newline: true) ⇒ Object



12
13
14
15
16
17
18
19
# File 'lib/piotrb_cli_utils/util.rb', line 12

def log(message, depth: 0, newline: true)
  message = Array(message)
  message.each do |m|
    indent = '  ' * depth
    print indent + m
    print "\n" if newline
  end
end