summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorDaniel Pittman <daniel@puppetlabs.com>2011-04-04 11:19:26 -0700
committerDaniel Pittman <daniel@puppetlabs.com>2011-04-04 13:32:04 -0700
commitcec3b6e2627ea2340e46c2e498f4d41522140094 (patch)
tree412a4c4af579e47abfcd21a33c9889854fffd470 /lib
parent5a0b547f3289cb8e13b197d021322e03d05bee8e (diff)
downloadpuppet-cec3b6e2627ea2340e46c2e498f4d41522140094.tar.gz
puppet-cec3b6e2627ea2340e46c2e498f4d41522140094.tar.xz
puppet-cec3b6e2627ea2340e46c2e498f4d41522140094.zip
(#6749) Extract the action from the arguments cleanly.
This adds a test to verify that we are correctly removing the action name from the set of arguments passed to the string action, then cleans up the previous code so we don't need to mutilate the command line arguments: we can just extract it from the resultant set of information. Reviewed-By: Nick Lewis <nick@puppetlabs.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/puppet/application/string_base.rb8
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/puppet/application/string_base.rb b/lib/puppet/application/string_base.rb
index a082ba0e2..8284a3185 100644
--- a/lib/puppet/application/string_base.rb
+++ b/lib/puppet/application/string_base.rb
@@ -84,7 +84,6 @@ class Puppet::Application::StringBase < Puppet::Application
raise ArgumentError, "#{@string} does not have an #{item.inspect} action!"
end
@action = action
- command_line.args.delete_at(index)
end
end
@@ -105,7 +104,12 @@ class Puppet::Application::StringBase < Puppet::Application
# 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 << options
end