diff options
author | Michael Stahnke <stahnma@puppetlabs.com> | 2011-08-05 09:23:49 -0700 |
---|---|---|
committer | Michael Stahnke <stahnma@puppetlabs.com> | 2011-08-05 09:23:49 -0700 |
commit | 3daea902b29cfd8e126ed64247ddf28aa5ad3d76 (patch) | |
tree | cda7fff4d06c7f3607a84b260fd71adfd9704e3b /lib/puppet/interface/action_manager.rb | |
parent | c8835ad0275c350b57884b81e485d9fc16699a21 (diff) | |
parent | 2185bb2804aeef6b419667951b2157b01404c694 (diff) | |
download | puppet-3daea902b29cfd8e126ed64247ddf28aa5ad3d76.tar.gz puppet-3daea902b29cfd8e126ed64247ddf28aa5ad3d76.tar.xz puppet-3daea902b29cfd8e126ed64247ddf28aa5ad3d76.zip |
Merge branch '2.7.x' into 2.7rc
Diffstat (limited to 'lib/puppet/interface/action_manager.rb')
-rw-r--r-- | lib/puppet/interface/action_manager.rb | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/lib/puppet/interface/action_manager.rb b/lib/puppet/interface/action_manager.rb index fbf588d7d..5c9af4f96 100644 --- a/lib/puppet/interface/action_manager.rb +++ b/lib/puppet/interface/action_manager.rb @@ -7,13 +7,14 @@ module Puppet::Interface::ActionManager require 'puppet/interface/action_builder' @actions ||= {} - @default_action ||= nil raise "Action #{name} already defined for #{self}" if action?(name) + action = Puppet::Interface::ActionBuilder.build(self, name, &block) - if action.default - raise "Actions #{@default_action.name} and #{name} cannot both be default" if @default_action - @default_action = action + + if action.default and current = get_default_action + raise "Actions #{current.name} and #{name} cannot both be default" end + @actions[action.name] = action end @@ -61,7 +62,11 @@ module Puppet::Interface::ActionManager end def get_default_action - @default_action + default = actions.map {|x| get_action(x) }.select {|x| x.default } + if default.length > 1 + raise "The actions #{default.map(&:name).join(", ")} cannot all be default" + end + default.first end def action?(name) |