diff options
| author | Daniel Pittman <daniel@puppetlabs.com> | 2011-04-28 10:57:51 -0700 |
|---|---|---|
| committer | Daniel Pittman <daniel@puppetlabs.com> | 2011-04-28 10:57:51 -0700 |
| commit | db14f1240be7e20ba04c0fdf448044b36ce24ceb (patch) | |
| tree | 124ebc6761561c0d94f9a314e1a169aae90a8355 /lib/puppet/application | |
| parent | ebf49f98357f93b33e09c0ecbdee1c5c2db87569 (diff) | |
| parent | 632a0a0042ebf2e7ef209ce30005833ccee6e77b (diff) | |
| download | puppet-db14f1240be7e20ba04c0fdf448044b36ce24ceb.tar.gz puppet-db14f1240be7e20ba04c0fdf448044b36ce24ceb.tar.xz puppet-db14f1240be7e20ba04c0fdf448044b36ce24ceb.zip | |
Merge branch 'feature/2.7.x/7160-support-json-externally' into 2.7.x
Diffstat (limited to 'lib/puppet/application')
| -rw-r--r-- | lib/puppet/application/face_base.rb | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/lib/puppet/application/face_base.rb b/lib/puppet/application/face_base.rb index 257d51f75..d28a8af3b 100644 --- a/lib/puppet/application/face_base.rb +++ b/lib/puppet/application/face_base.rb @@ -15,8 +15,14 @@ class Puppet::Application::FaceBase < Puppet::Application Puppet::Util::Log.level = :info end - option("--render-as FORMAT") do |arg| - @render_as = arg.to_sym + option("--render-as FORMAT") do |_arg| + format = _arg.to_sym + unless @render_method = Puppet::Network::FormatHandler.format(format) + unless format == :for_humans or format == :json + raise ArgumentError, "I don't know how to render '#{format}'" + end + end + @render_as = format end option("--mode RUNMODE", "-r") do |arg| @@ -38,13 +44,10 @@ class Puppet::Application::FaceBase < Puppet::Application if format == :for_humans then render_for_humans(result) + elsif format == :json or @render_method == "to_pson" + PSON::pretty_generate(result, :allow_nan => true, :max_nesting => false) else - render_method = Puppet::Network::FormatHandler.format(format).render_method - if render_method == "to_pson" - PSON::pretty_generate(result, :allow_nan => true, :max_nesting => false) - else - result.send(render_method) - end + result.send(@render_method) end end |
