[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:25 UTC 2011


The following commit has been merged in the experimental branch:
commit fe6d59528d18e9aa989f48d364868a5a105017a5
Author: Daniel Pittman <daniel at puppetlabs.com>
Date:   Mon Apr 11 22:04:28 2011 -0700

    (#6962) Integrate legacy subcommands into the help face.
    
    Previously we would only emit help for a face; now we fully integrate legacy
    subcommands in the sense that asking for face-level help will emit their
    entire help text.
    
    Asking for any action subsequent will raise an error: this is an annoyingly
    inconsistent behaviour, but there isn't a saner definition of the change.
    
    Reviewed-By: Matt Robinson <matt at puppetlabs.com>

diff --git a/lib/puppet/faces/help.rb b/lib/puppet/faces/help.rb
index 29a4a62..1d8abe2 100644
--- a/lib/puppet/faces/help.rb
+++ b/lib/puppet/faces/help.rb
@@ -35,8 +35,16 @@ Puppet::Faces.define(:help, '0.0.1') do
 
       # 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
+
+      if facename then
+        if legacy_applications.include? facename then
+          actionname and raise ArgumentError, "Legacy subcommands don't take actions"
+          return Puppet::Application[facename].help
+        else
+          face = Puppet::Faces[facename.to_sym, version]
+          actionname and action = face.get_action(actionname.to_sym)
+        end
+      end
 
       case args.length
       when 0 then
diff --git a/spec/unit/faces/help_spec.rb b/spec/unit/faces/help_spec.rb
index f2aeb44..cd74a5b 100644
--- a/spec/unit/faces/help_spec.rb
+++ b/spec/unit/faces/help_spec.rb
@@ -87,4 +87,26 @@ describe Puppet::Faces[:help, '0.0.1'] do
       it { should_not include name }
     end
   end
+
+  context "help for legacy applications" do
+    subject { Puppet::Faces[:help, :current] }
+    let :appname do subject.legacy_applications.first end
+
+    # This test is purposely generic, so that as we eliminate legacy commands
+    # we don't get into a loop where we either test a face-based replacement
+    # and fail to notice breakage, or where we have to constantly rewrite this
+    # test and all. --daniel 2011-04-11
+    it "should return the legacy help when given the subcommand" do
+      help = subject.help(appname)
+      help.should =~ /puppet-#{appname}/
+      %w{SYNOPSIS USAGE DESCRIPTION OPTIONS COPYRIGHT}.each do |heading|
+        help.should =~ /^#{heading}$/
+      end
+    end
+
+    it "should fail when asked for an action on a legacy command" do
+      expect { subject.help(appname, :whatever) }.
+        to raise_error ArgumentError, /Legacy subcommands don't take actions/
+    end
+  end
 end

-- 
Puppet packaging for Debian



More information about the Pkg-puppet-devel mailing list