class Inspec::Config
def finalize_parse_reporters(options) # rubocop:disable Metrics/AbcSize
def finalize_parse_reporters(options) # rubocop:disable Metrics/AbcSize # default to cli report for ad-hoc runners options["reporter"] = ["cli"] if options["reporter"].nil? # parse out cli to proper report format if options["reporter"].is_a?(Array) reports = {} options["reporter"].each do |report| reporter_name, destination = report.split(":", 2) if destination.nil? || destination.strip == "-" reports[reporter_name] = { "stdout" => true } else reports[reporter_name] = { "file" => destination, "stdout" => false, } reports[reporter_name]["target_id"] = options["target_id"] if options["target_id"] end end options["reporter"] = reports end # add in stdout if not specified if options["reporter"].is_a?(Hash) options["reporter"].each do |reporter_name, config| options["reporter"][reporter_name] = {} if config.nil? options["reporter"][reporter_name]["stdout"] = true if options["reporter"][reporter_name].empty? options["reporter"][reporter_name]["target_id"] = options["target_id"] if options["target_id"] end end validate_reporters!(options["reporter"]) options end