lib/inspec/cli.rb in inspec-1.51.25 vs lib/inspec/cli.rb in inspec-2.0.16
- old
+ new
@@ -160,16 +160,10 @@
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
@@ -182,20 +176,30 @@
desc 'detect', 'detect the target OS'
target_options
option :format, type: :string
def detect
o = opts(:detect).dup
- o[:command] = 'os.params'
+ o[:command] = 'platform.params'
(_, res) = run_command(o)
if o['format'] == 'json'
puts res.to_json
else
- headline('Operating System Details')
- %w{name family release arch}.each { |item|
- puts format('%-10s %s', item.to_s.capitalize + ':',
- mark_text(res[item.to_sym]))
+ headline('Platform Details')
+ %w{name families release arch}.each { |item|
+ data = res[item.to_sym]
+
+ # 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?
+
+ puts format('%-10s %s', item.to_s.capitalize + ':', mark_text(data))
}
end
+ rescue ArgumentError, RuntimeError, Train::UserError => e
+ $stderr.puts e.message
+ exit 1
rescue StandardError => e
pretty_handle_exception(e)
end
desc 'shell', 'open an interactive debugging shell'