summaryrefslogtreecommitdiffstats
path: root/lib/puppet/application
diff options
context:
space:
mode:
authorDaniel Pittman <daniel@puppetlabs.com>2011-04-18 15:23:03 -0700
committerDaniel Pittman <daniel@puppetlabs.com>2011-04-19 10:53:42 -0700
commit5938452dccc8c925bc6275a62ae96f50916cc239 (patch)
tree16553eb01610d066c529230cf5f5c4f546a63d75 /lib/puppet/application
parent5258e06a39e11c2cc1951af9235605a29a155c36 (diff)
(#7013) Strip out old face-wide rendering defaults.
Now we want to support action-based rendering, it is super-hard to define the semantics around defaulting where things are unspecified: the execution context (CLI, HTTP, etc) vs the face, vs the action all have different semantics. Without solving the problem of how we express all that context and those semantics down in the action, especially one written by a third party, this just becomes a box of counter-intuitive and annoying semantics and edge-cases. Reviewed-By: Max Martin <max@puppetlabs.com>
Diffstat (limited to 'lib/puppet/application')
-rw-r--r--lib/puppet/application/face_base.rb15
1 files changed, 7 insertions, 8 deletions
diff --git a/lib/puppet/application/face_base.rb b/lib/puppet/application/face_base.rb
index 947204d68..456f0c610 100644
--- a/lib/puppet/application/face_base.rb
+++ b/lib/puppet/application/face_base.rb
@@ -15,8 +15,8 @@ class Puppet::Application::FaceBase < Puppet::Application
Puppet::Util::Log.level = :info
end
- option("--format FORMAT") do |arg|
- @format = arg.to_sym
+ option("--render-as FORMAT") do |arg|
+ @render_as = arg.to_sym
end
option("--mode RUNMODE", "-r") do |arg|
@@ -26,7 +26,7 @@ class Puppet::Application::FaceBase < Puppet::Application
end
- attr_accessor :face, :action, :type, :arguments, :format
+ attr_accessor :face, :action, :type, :arguments, :render_as
attr_writer :exit_code
# This allows you to set the exit code if you don't want to just exit
@@ -37,8 +37,8 @@ class Puppet::Application::FaceBase < Puppet::Application
# Override this if you need custom rendering.
def render(result)
- if format then
- render_method = Puppet::Network::FormatHandler.format(format).render_method
+ if render_as then
+ render_method = Puppet::Network::FormatHandler.format(render_as).render_method
if render_method == "to_pson"
jj result
else
@@ -85,9 +85,8 @@ class Puppet::Application::FaceBase < Puppet::Application
# REVISIT: These should be configurable versions, through a global
# '--version' option, but we don't implement that yet... --daniel 2011-03-29
- @type = self.class.name.to_s.sub(/.+:/, '').downcase.to_sym
- @face = Puppet::Face[@type, :current]
- @format = @face.default_format
+ @type = self.class.name.to_s.sub(/.+:/, '').downcase.to_sym
+ @face = Puppet::Face[@type, :current]
# Now, walk the command line and identify the action. We skip over
# arguments based on introspecting the action and all, and find the first