diff options
author | Jacob Helwig <jacob@puppetlabs.com> | 2011-04-12 11:17:07 -0700 |
---|---|---|
committer | Jacob Helwig <jacob@puppetlabs.com> | 2011-04-12 11:17:07 -0700 |
commit | cfcc4285e2e505700e16142deb10f58523a05f08 (patch) | |
tree | 75aa6acaf57de80e1f07b2e59b7c6f978501f709 | |
parent | 6b97242d5ca2cc28cc11e6f253f76fda90255d7f (diff) | |
parent | a75f0f9bc7ea1e03dc3a19fba8fae61165ab2b05 (diff) | |
download | facter-cfcc4285e2e505700e16142deb10f58523a05f08.tar.gz facter-cfcc4285e2e505700e16142deb10f58523a05f08.tar.xz facter-cfcc4285e2e505700e16142deb10f58523a05f08.zip |
Merge branch 'tickets/master/7039-multiple-facts-same-file'
* tickets/master/7039-multiple-facts-same-file:
(#7039) Pre-load all facts when requesting a single fact
-rw-r--r-- | lib/facter/application.rb | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/lib/facter/application.rb b/lib/facter/application.rb index 6b351b1..bd68149 100644 --- a/lib/facter/application.rb +++ b/lib/facter/application.rb @@ -9,19 +9,21 @@ module Facter # Accept fact names to return from the command line names = argv - # Create the facts hash that is printed to standard out - if names.empty? - facts = Facter.to_hash - else + # Create the facts hash that is printed to standard out. + # Pre-load all of the facts, since we can have multiple facts + # per file, and since we can't know ahead of time which file a + # fact will be in, we'll need to load every file. + facts = Facter.to_hash + unless names.empty? facts = {} - names.each { |name| + names.each do |name| begin facts[name] = Facter.value(name) rescue => error $stderr.puts "Could not retrieve #{name}: #{error}" exit 10 end - } + end end # Print the facts as YAML and exit |