summaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authorluke <luke@1f5c1d6a-bddf-0310-8f58-fc49e503516a>2006-09-19 06:55:52 +0000
committerluke <luke@1f5c1d6a-bddf-0310-8f58-fc49e503516a>2006-09-19 06:55:52 +0000
commitfe0f2f204fdd5d4c48af93d691cce53061cd1ded (patch)
tree68acc999c6e42c6f0eda9afa00c81886c5425ba4 /bin
parent4abbce9119f91179aaa7aeb2f92466cc201a9079 (diff)
downloadfacter-fe0f2f204fdd5d4c48af93d691cce53061cd1ded.tar.gz
facter-fe0f2f204fdd5d4c48af93d691cce53061cd1ded.tar.xz
facter-fe0f2f204fdd5d4c48af93d691cce53061cd1ded.zip
Adding yaml support, as requested in #24
git-svn-id: http://reductivelabs.com/svn/facter/trunk@170 1f5c1d6a-bddf-0310-8f58-fc49e503516a
Diffstat (limited to 'bin')
-rwxr-xr-xbin/facter13
1 files changed, 13 insertions, 0 deletions
diff --git a/bin/facter b/bin/facter
index d5b380f..10389ba 100755
--- a/bin/facter
+++ b/bin/facter
@@ -59,14 +59,21 @@ result = GetoptLong.new(
[ "--version", "-v", GetoptLong::NO_ARGUMENT ],
[ "--help", "-h", GetoptLong::NO_ARGUMENT ],
[ "--debug", "-d", GetoptLong::NO_ARGUMENT ],
+ [ "--yaml", "-y", GetoptLong::NO_ARGUMENT ],
[ "--config", "-c", GetoptLong::REQUIRED_ARGUMENT ]
)
+options = {
+ :yaml => false
+}
+
result.each { |opt,arg|
case opt
when "--version"
puts "%s" % Facter.version
exit
+ when "--yaml"
+ options[:yaml] = true
when "--debug"
Facter.debugging(1)
when "--help"
@@ -113,6 +120,12 @@ else
}
end
+if options[:yaml]
+ require 'yaml'
+ puts YAML.dump(facts)
+ exit(0)
+end
+
facts.sort { |a, b| a[0].to_s <=> b[0].to_s }.each { |name,value|
if facts.length == 1
unless value.nil?