[Pkg-puppet-devel] [SCM] Puppet packaging for Debian branch, upstream, updated. 2.6.5-303-gfcfa26a

Daniel Pittman daniel at rimspace.net
Thu Mar 17 10:47:42 UTC 2011


The following commit has been merged in the upstream branch:
commit 309b9320feef3e1a9459c7a26d10955b4d6b549c
Author: Daniel Pittman <daniel at rimspace.net>
Date:   Tue Feb 22 11:25:03 2011 -0800

    (#5552) Display help when no subcommand is given.
    
    Previously, when the command line was empty we would try and invoke an empty
    method; this was less helpful than telling people what they could actually do,
    so we adapt our code to do precisely that.
    
    Paired-With: Jesse Wolfe <jesse at puppetlabs.com>
    Signed-off-by: Daniel Pittman <daniel at puppetlabs.com>

diff --git a/lib/puppet/application/cert.rb b/lib/puppet/application/cert.rb
index c8aad18..ee59b7e 100644
--- a/lib/puppet/application/cert.rb
+++ b/lib/puppet/application/cert.rb
@@ -89,7 +89,13 @@ class Puppet::Application::Cert < Puppet::Application
   def parse_options
     # handle the bareword subcommand pattern.
     result = super
-    self.subcommand ||= self.command_line.args.shift
+    unless self.subcommand then
+      if sub = self.command_line.args.shift then
+        self.subcommand = sub
+      else
+        help
+      end
+    end
     result
   end
 end
diff --git a/spec/unit/application/cert_spec.rb b/spec/unit/application/cert_spec.rb
index 2f57d07..b325791 100755
--- a/spec/unit/application/cert_spec.rb
+++ b/spec/unit/application/cert_spec.rb
@@ -189,6 +189,16 @@ describe Puppet::Application::Cert do
       @cert_app.ca = @ca
     end
 
+    it "should not fail when no command is given" do
+      # Make the help method silent for testing; this is a bit nasty, but we
+      # can't identify a cleaner method.  Help welcome. --daniel 2011-02-22
+      Puppet.features.stubs(:usage?).returns(false)
+      @cert_app.stubs(:puts)
+
+      @cert_app.command_line.stubs(:args).returns([])
+      expect { @cert_app.parse_options }.should raise_error SystemExit
+    end
+
     %w{list revoke generate sign print verify fingerprint}.each do |cmd|
       short = cmd[0,1]
       [cmd, "--#{cmd}", "-#{short}"].each do |option|

-- 
Puppet packaging for Debian



More information about the Pkg-puppet-devel mailing list