diff options
-rw-r--r-- | lib/puppet/application/string_base.rb | 14 | ||||
-rwxr-xr-x | spec/unit/application/string_base_spec.rb | 6 |
2 files changed, 14 insertions, 6 deletions
diff --git a/lib/puppet/application/string_base.rb b/lib/puppet/application/string_base.rb index 06e5789be..76b0a46fd 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 753d911d1..cd24b6c49 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 |