diff options
| author | Daniel Pittman <daniel@puppetlabs.com> | 2011-04-27 18:30:27 -0700 |
|---|---|---|
| committer | Daniel Pittman <daniel@puppetlabs.com> | 2011-04-28 10:50:51 -0700 |
| commit | 80adaea6319b2aca81fd3d9b1d0061152b6c7db2 (patch) | |
| tree | cead79a1b4d886fd824157d11b26b189c8a68632 /lib/puppet | |
| parent | ebf49f98357f93b33e09c0ecbdee1c5c2db87569 (diff) | |
| download | puppet-80adaea6319b2aca81fd3d9b1d0061152b6c7db2.tar.gz puppet-80adaea6319b2aca81fd3d9b1d0061152b6c7db2.tar.xz puppet-80adaea6319b2aca81fd3d9b1d0061152b6c7db2.zip | |
(#7160) Support 'json' as a rendering method for CLI faces.
We already had some specialized support for rendering JSON using the PSON
libraries; this just extends that to recognize the request on the command line
for json to be identical to a request for pson.
Theoretically we should also support the format in our network rendering code,
but that is a much bigger change, in established code, that has more chance of
destabilizing the whole release.
Reviewed-By: Max Martin <max@puppetlabs.com>
Diffstat (limited to 'lib/puppet')
| -rw-r--r-- | lib/puppet/application/face_base.rb | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/lib/puppet/application/face_base.rb b/lib/puppet/application/face_base.rb index 257d51f75..cc62257c7 100644 --- a/lib/puppet/application/face_base.rb +++ b/lib/puppet/application/face_base.rb @@ -36,15 +36,18 @@ class Puppet::Application::FaceBase < Puppet::Application result = hook.call(result) end + begin + render_method = Puppet::Network::FormatHandler.format(format).render_method + rescue + render_method = nil + end + 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 |
