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


The following commit has been merged in the experimental branch:
commit 0950d09d12ec06e97915d264e8724e736c84e36a
Author: Daniel Pittman <daniel at puppetlabs.com>
Date:   Mon Apr 4 14:46:21 2011 -0700

    (#6949) Fix passing positional arguments to actions.
    
    We had a logic failure that didn't pass positional arguments at all, but which
    our testing didn't verify.  This entirely broke things.  Now fixed, and a test
    added to ensure we don't bug out further...
    
    Reviewed-By: Pieter van de Bruggen <pieter at puppetlabs.com>

diff --git a/lib/puppet/application/string_base.rb b/lib/puppet/application/string_base.rb
index 06e5789..76b0a46 100644
--- a/lib/puppet/application/string_base.rb
+++ b/lib/puppet/application/string_base.rb
@@ -104,16 +104,18 @@ class Puppet::Application::StringBase < Puppet::Application
   def setup
     Puppet::Util::Log.newdestination :console
 
-    # We copy all of the app options to the end of the call; This allows each
-    # action to read in the options.  This replaces the older model where we
-    # would invoke the action with options set as global state in the
-    # interface object.  --daniel 2011-03-28
-    #
+    @arguments = command_line.args
+
     # Note: because of our definition of where the action is set, we end up
     # with it *always* being the first word of the remaining set of command
     # line arguments.  So, strip that off when we construct the arguments to
     # pass down to the string action. --daniel 2011-04-04
-    @arguments = command_line.args[1, -1] || []
+    @arguments.delete_at(0)
+
+    # We copy all of the app options to the end of the call; This allows each
+    # action to read in the options.  This replaces the older model where we
+    # would invoke the action with options set as global state in the
+    # interface object.  --daniel 2011-03-28
     @arguments << options
   end
 
diff --git a/spec/unit/application/string_base_spec.rb b/spec/unit/application/string_base_spec.rb
index 753d911..cd24b6c 100755
--- a/spec/unit/application/string_base_spec.rb
+++ b/spec/unit/application/string_base_spec.rb
@@ -127,6 +127,12 @@ describe Puppet::Application::StringBase do
       app.preinit and app.parse_options and app.setup
       app.arguments.should == [{ :mandatory => "--bar" }]
     end
+
+    it "should pass positional arguments" do
+      app.command_line.stubs(:args).returns %w{--mandatory --bar foo bar baz quux}
+      app.preinit and app.parse_options and app.setup
+      app.arguments.should == ['bar', 'baz', 'quux', { :mandatory => "--bar" }]
+    end
   end
 
   describe "#main" do

-- 
Puppet packaging for Debian



More information about the Pkg-puppet-devel mailing list