Module: NexClient::Commands::Helpers

Included in:
Addons, Apps, CubeInstances, CubeTemplates, Domains, Organizations, Racks, SslCertificates, Users
Defined in:
lib/nex_client/commands/helpers.rb

Constant Summary collapse

LOG_COLORS =
[:cyan,:green,:red,:yellow,:magenta]

Instance Method Summary collapse

Instance Method Details

#display_logs(logs) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
# File 'lib/nex_client/commands/helpers.rb', line 22

def display_logs(logs)
  color_index = 0
  logs.each do |container_id,log_lines|
    color_index = (color_index + 1) % LOG_COLORS.size
    puts "\n"
    puts "Node: #{container_id}".colorize(LOG_COLORS[color_index])
    puts "-"*50
    puts log_lines.join("\n")
  end
  puts "\n"
end

#display_record_errors(record) ⇒ Object



8
9
10
11
12
# File 'lib/nex_client/commands/helpers.rb', line 8

def display_record_errors(record)
  record.errors.messages.each do |k,v|
    v.each { |m| puts "#{k} #{m}" }
  end
end

#error(msg) ⇒ Object



18
19
20
# File 'lib/nex_client/commands/helpers.rb', line 18

def error(msg)
  puts msg.colorize(:red)
end

#success(msg) ⇒ Object



14
15
16
# File 'lib/nex_client/commands/helpers.rb', line 14

def success(msg)
  puts msg.colorize(:green)
end