From fe0f2f204fdd5d4c48af93d691cce53061cd1ded Mon Sep 17 00:00:00 2001 From: luke Date: Tue, 19 Sep 2006 06:55:52 +0000 Subject: Adding yaml support, as requested in #24 git-svn-id: http://reductivelabs.com/svn/facter/trunk@170 1f5c1d6a-bddf-0310-8f58-fc49e503516a --- bin/facter | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'bin') 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? -- cgit