Method: Inspec::InspecCLI#exec

Defined in:
lib/inspec/cli.rb

#exec(*targets) ⇒ Object



160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
# File 'lib/inspec/cli.rb', line 160

def exec(*targets)
  o = opts(:exec).dup
  diagnose(o)
  configure_logger(o)

  # TODO: REMOVE for inspec 2.0
  if o.key?('cache')
    o[:vendor_cache] = o[:cache]
    o[:logger].warn '[DEPRECATED] The use of `--cache` is being deprecated in InSpec 2.0. Please use `--vendor-cache` instead.'
  end

  runner = Inspec::Runner.new(o)
  targets.each { |target| runner.add_target(target) }

  exit runner.run
rescue ArgumentError, RuntimeError, Train::UserError => e
  $stderr.puts e.message
  exit 1
rescue StandardError => e
  pretty_handle_exception(e)
end