On 4 November 2010 04:20, James Turnbull <ja...@lovedthanlost.net> wrote:
> From: John E. Vincent <lusis.org+github....@gmail.com>

We need testing on 1.8.1 upwards. Do we not want json/pure rather than json?


> Signed-off-by: James Turnbull <ja...@lovedthanlost.net>
> ---
>  bin/facter                |    5 ++++-
>  lib/facter/application.rb |   13 +++++++++++++
>  2 files changed, 17 insertions(+), 1 deletions(-)
>
> diff --git a/bin/facter b/bin/facter
> index 9d3b49c..622d72e 100755
> --- a/bin/facter
> +++ b/bin/facter
> @@ -6,7 +6,7 @@
>  #
>  # = Usage
>  #
> -#   facter [-d|--debug] [-h|--help] [-p|--puppet] [-v|--version] [-y|--yaml] 
> [fact] [fact] [...]
> +#   facter [-d|--debug] [-h|--help] [-p|--puppet] [-v|--version] [-y|--yaml] 
> [-j|--json] [fact] [fact] [...]
>  #
>  # = Description
>  #
> @@ -21,6 +21,9 @@
>  # yaml::
>  #   Emit facts in YAML format.
>  #
> +# json::
> +#   Emit facts in JSON format.
> +#
>  # puppet::
>  #   Load the Puppet libraries, thus allowing Facter to load Puppet-specific 
> facts.
>  #
> diff --git a/lib/facter/application.rb b/lib/facter/application.rb
> index 9de9249..9d6bc34 100644
> --- a/lib/facter/application.rb
> +++ b/lib/facter/application.rb
> @@ -31,6 +31,18 @@ module Facter
>         exit(0)
>       end
>
> +      # Print the facts as JSON and exit
> +      if options[:json]
> +        begin
> +          require 'json'
> +          puts JSON.dump(facts)
> +          exit(0)
> +        rescue LoadError
> +          $stderr.puts "You do not have JSON support in your version of 
> Ruby. JSON output disabled"
> +          exit(1)
> +        end
> +      end
> +
>       # Print the value of a single fact, otherwise print a list sorted by 
> fact
>       # name and separated by "=>"
>       if facts.length == 1
> @@ -58,6 +70,7 @@ module Facter
>       options = {}
>       OptionParser.new do |opts|
>         opts.on("-y", "--yaml")   { |v| options[:yaml]   = v }
> +        opts.on("-j", "--json")   { |v| options[:json]   = v }
>         opts.on(      "--trace")  { |v| options[:trace]  = v }
>         opts.on("-d", "--debug")  { |v| Facter.debugging(1) }
>         opts.on("-t", "--timing") { |v| Facter.timing(1) }
> --
> 1.7.2.3
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Puppet Developers" group.
> To post to this group, send email to puppet-...@googlegroups.com.
> To unsubscribe from this group, send email to 
> puppet-dev+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/puppet-dev?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Developers" group.
To post to this group, send email to puppet-...@googlegroups.com.
To unsubscribe from this group, send email to 
puppet-dev+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/puppet-dev?hl=en.

Reply via email to