225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
|
# File 'lib/inspec/cli.rb', line 225
def shell_func
o = opts(:shell).dup
diagnose(o)
o[:debug_shell] = true
log_device = suppress_log_output?(o) ? nil : STDOUT
o[:logger] = Logger.new(log_device)
o[:logger].level = get_log_level(o.log_level)
if o[:command].nil?
runner = Inspec::Runner.new(o)
return Inspec::Shell.new(runner).start
end
run_type, res = run_command(o)
exit res unless run_type == :ruby_eval
res = (res.respond_to?(:to_json) ? res.to_json : JSON.dump(res)) if o['reporter']&.keys&.include?('json')
puts res
exit 0
rescue RuntimeError, Train::UserError => e
$stderr.puts e.message
rescue StandardError => e
pretty_handle_exception(e)
end
|