diff options
| -rw-r--r-- | lib/puppet/application/man.rb | 4 | ||||
| -rw-r--r-- | lib/puppet/face/man.rb | 47 |
2 files changed, 51 insertions, 0 deletions
diff --git a/lib/puppet/application/man.rb b/lib/puppet/application/man.rb new file mode 100644 index 000000000..1ecc4d691 --- /dev/null +++ b/lib/puppet/application/man.rb @@ -0,0 +1,4 @@ +require 'puppet/application/face_base' + +class Puppet::Application::Man < Puppet::Application::FaceBase +end diff --git a/lib/puppet/face/man.rb b/lib/puppet/face/man.rb new file mode 100644 index 000000000..44a339490 --- /dev/null +++ b/lib/puppet/face/man.rb @@ -0,0 +1,47 @@ +require 'puppet/face' +require 'pathname' +require 'erb' + +Puppet::Face.define(:man, '0.0.1') do + copyright "Puppet Labs", 2011 + license "Apache 2 license; see COPYING" + + summary "Display Puppet subcommand manual pages." + + action(:man) do + summary "Display the manual page for a face." + arguments "<face>" + returns "The man data, in markdown format, suitable for consumption by Ronn." + examples <<-'EOT' + Get the manual page for a face: + + $ puppet man facts + EOT + + default + when_invoked do |name, options| + if legacy_applications.include? name then + return Puppet::Application[name].help + end + + face = Puppet::Face[name.to_sym, :current] + + file = (Pathname(__FILE__).dirname + "help" + 'man.erb') + erb = ERB.new(file.read, nil, '-') + erb.filename = file.to_s + + # Run the ERB template in our current binding, including all the local + # variables we established just above. --daniel 2011-04-11 + return erb.result(binding) + end + end + + def legacy_applications + # The list of applications, less those that are duplicated as a face. + Puppet::Util::CommandLine.available_subcommands.reject do |appname| + Puppet::Face.face? appname.to_sym, :current or + # ...this is a nasty way to exclude non-applications. :( + %w{face_base indirection_base}.include? appname + end + end +end |
