def self.run(argv)
options = parse(argv)
names = argv
unless names.empty?
facts = {}
names.each do |name|
begin
facts[name] = Facter.value(name)
rescue => error
Facter.log_exception(error, "Could not retrieve #{name}: #{error.message}")
exit(10)
end
end
end
facts ||= Facter.to_hash
output = nil
if options[:yaml]
output = Facter::Util::Formatter.format_yaml(facts)
elsif options[:json]
output = Facter::Util::Formatter.format_json(facts)
elsif options[:plaintext]
output = Facter::Util::Formatter.format_plaintext(facts)
else
output = Facter::Util::Formatter.format_plaintext(facts)
end
puts output
exit(0)
rescue => e
Facter.log_exception(e)
exit(12)
end