[Pkg-puppet-devel] [SCM] Puppet packaging for Debian branch, experimental, updated. debian/2.6.8-1-844-g7ec39d5

Daniel Pittman daniel at puppetlabs.com
Tue May 10 08:13:22 UTC 2011


The following commit has been merged in the experimental branch:
commit 657082755a20da801b4c679eff296053380c61b6
Author: Daniel Pittman <daniel at puppetlabs.com>
Date:   Mon Apr 11 16:19:21 2011 -0700

    (#6962) Add summary help for actions on an individual face.
    
    We now emit the summary of actions for an individual face, in the same format
    as the summary of available faces.  This moves forward through the feature set
    defined for the help subcommand.
    
    Reviewed-By: Matt Robinson <matt at puppetlabs.com>

diff --git a/lib/puppet/faces/help.rb b/lib/puppet/faces/help.rb
index 2eb2869..17ce3ec 100644
--- a/lib/puppet/faces/help.rb
+++ b/lib/puppet/faces/help.rb
@@ -7,6 +7,8 @@ Puppet::Faces.define(:help, '0.0.1') do
   summary "Displays help about puppet subcommands"
 
   action(:help) do
+    summary "Display help about faces and their actions."
+
     option "--version VERSION" do
       desc "Which version of the interface to show help for"
     end
@@ -20,15 +22,27 @@ Puppet::Faces.define(:help, '0.0.1') do
         raise ArgumentError, "help only takes two (optional) arguments, a face name, and an action"
       end
 
-      if options[:version] and options[:version] !~ /^current$/i then
-        version = options[:version]
-      else
-        version = :current
+      version = :current
+      if options.has_key? :version then
+        if options[:version].to_s !~ /^current$/i then
+          version = options[:version]
+        else
+          if args.length == 0 then
+            raise ArgumentError, "version only makes sense when a face is given"
+          end
+        end
       end
 
+      # Name those parameters...
+      facename, actionname = args
+      face   = facename ? Puppet::Faces[facename.to_sym, version] : nil
+      action = (face and actionname) ? face.get_action(actionname.to_sym) : nil
+
+      # Finally, build up the help text.  Maybe ERB would have been nicer
+      # after all.  Oh, well. --daniel 2011-04-11
       message = []
       if args.length == 0 then
-        message << "Use: puppet [options] <subcommand> <action>"
+        message << "Use: puppet <subcommand> [options] <action> [options]"
         message << ""
         message << "Available subcommands, from Puppet Faces:"
         Puppet::Faces.faces.sort.each do |name|
@@ -44,18 +58,28 @@ Puppet::Faces.define(:help, '0.0.1') do
             message << format(HelpSummaryFormat, appname, summary)
           end
         end
-      else
-        face = Puppet::Faces[args[0].to_sym, version]
-        if args[1] then
-          action = face.get_action args[1].to_sym
-        else
-          action = nil
-        end
 
-        help = []
-        face.actions.each do |action|
-          help << "Action: #{action}"
+        message << ""
+        message << <<EOT.split("\n")
+See 'puppet help <subcommand> <action>' for help on a specific subcommand action.
+See 'puppet help <subcommand>' for help on a specific subcommand.
+See 'puppet man  <subcommand>' for the full man page.
+Puppet v#{Puppet::PUPPETVERSION}
+EOT
+      elsif args.length == 1 then
+        message << "Use: puppet #{face.name} [options] <action> [options]"
+        message << ""
+
+        message << "Available actions:"
+        face.actions.each do |actionname|
+          action = face.get_action(actionname)
+          message << format(HelpSummaryFormat, action.name, action.summary)
         end
+
+      elsif args.length == 2
+        "REVISIT: gotta write this code."
+      else
+        raise ArgumentError, "help only takes two arguments, a face name and an action"
       end
 
       message
diff --git a/spec/unit/faces/help_spec.rb b/spec/unit/faces/help_spec.rb
index 1399abf..61f1947 100644
--- a/spec/unit/faces/help_spec.rb
+++ b/spec/unit/faces/help_spec.rb
@@ -100,4 +100,6 @@ describe Puppet::Faces[:help, '0.0.1'] do
       end
     end
   end
+
+  
 end

-- 
Puppet packaging for Debian



More information about the Pkg-puppet-devel mailing list