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


The following commit has been merged in the experimental branch:
commit 0c74495529bd697cdc42986882fc3efb4cdc9903
Author: Daniel Pittman <daniel at puppetlabs.com>
Date:   Mon Apr 4 11:35:46 2011 -0700

    (#6749) Handle options with inline arguments.
    
    We didn't correctly handle '--foo=bar' as having supplied an argument during
    the pre-parse phase.  Now we have a test for it, and a fix in the code.
    
    Reviewed-By: Nick Lewis <nick at puppetlabs.com>

diff --git a/lib/puppet/application/string_base.rb b/lib/puppet/application/string_base.rb
index 8284a31..06e5789 100644
--- a/lib/puppet/application/string_base.rb
+++ b/lib/puppet/application/string_base.rb
@@ -71,7 +71,11 @@ class Puppet::Application::StringBase < Puppet::Application
         option = @string.options.find { |a| item =~ /^-+#{a}\b/ }
         if option then
           option = @string.get_option(option)
-          if option.takes_argument? then
+          # If we have an inline argument, just carry on.  We don't need to
+          # care about optional vs mandatory in that case because we do a real
+          # parse later, and that will totally take care of raising the error
+          # when we get there. --daniel 2011-04-04
+          if option.takes_argument? and !item.index('=') then
             index += 1 unless
               (option.optional_argument? and command_line.args[index + 1] =~ /^-/)
           end
diff --git a/spec/unit/application/string_base_spec.rb b/spec/unit/application/string_base_spec.rb
index 5cfb835..71e6728 100755
--- a/spec/unit/application/string_base_spec.rb
+++ b/spec/unit/application/string_base_spec.rb
@@ -112,6 +112,12 @@ describe Puppet::Application::StringBase do
         app.action.name.should == :foo
         app.options.should == { :mandatory => "--bar" }
       end
+
+      it "should not skip when --foo=bar is given" do
+        app.command_line.stubs(:args).returns %w{--mandatory=bar --bar foo}
+        expect { app.preinit }.
+          should raise_error ArgumentError, /Unknown option "--bar"/
+      end
     end
   end
 

-- 
Puppet packaging for Debian



More information about the Pkg-puppet-devel mailing list