Method: Inspec::BaseCLI.detect

Defined in:
lib/inspec/base_cli.rb

.detect(params: {}, indent: 0, color: 39) ⇒ Object



197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
# File 'lib/inspec/base_cli.rb', line 197

def self.detect(params: {}, indent: 0, color: 39)
  str = ''
  params.each { |item, info|
    data = info

    # Format Array for better output if applicable
    data = data.join(', ') if data.is_a?(Array)

    # Do not output fields of data is missing ('unknown' is fine)
    next if data.nil?

    data = "\e[1m\e[#{color}m#{data}\e[0m"
    str << format("#{' ' * indent}%-10s %s\n", item.to_s.capitalize + ':', data)
  }
  str
end