Module: Puppet::Interface::OptionManager
- Included in:
- Puppet::Interface, Puppet::Interface
- Defined in:
- lib/puppet/interface/option_manager.rb
Overview
Instance Method Summary (collapse)
-
- (Object) add_option(option)
private
-
- (Object) display_global_options(*args)
(also: #display_global_option)
private
-
- (Object) get_option(name, with_inherited_options = true)
private
-
- (Object) option(*declaration, &block)
DSL
Declare that this app can take a specific option, and provide the code to do so.
-
- (Boolean) option?(name)
private
-
- (Object) options
private
-
- (Object) walk_inheritance_tree(start, sym)
private
Instance Method Details
- (Object) add_option(option) private
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/puppet/interface/option_manager.rb', line 48 def add_option(option) # @options collects the added options in the order they're declared. # @options_hash collects the options keyed by alias for quick lookups. ||= [] ||= {} option.aliases.each do |name| if conflict = get_option(name) then raise ArgumentError, "Option #{option} conflicts with existing option #{conflict}" end actions.each do |action| action = get_action(action) if conflict = action.get_option(name) then raise ArgumentError, "Option #{option} conflicts with existing option #{conflict} on #{action}" end end end << option.name option.aliases.each do |name| [name] = option end return option end |
- (Object) display_global_options(*args) private Also known as: display_global_option
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
11 12 13 14 15 16 17 18 19 |
# File 'lib/puppet/interface/option_manager.rb', line 11 def (*args) ||= [] [args].flatten.each do |refopt| raise ArgumentError, "Global option #{refopt} does not exist in Puppet.settings" unless Puppet.settings.include? refopt << refopt if refopt end .uniq! end |
- (Object) get_option(name, with_inherited_options = true) private
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/puppet/interface/option_manager.rb', line 82 def get_option(name, = true) ||= {} result = [name.to_sym] if result.nil? and then if self.is_a?(Class) and superclass.respond_to?(:get_option) result = superclass.get_option(name) elsif self.class.respond_to?(:get_option) result = self.class.get_option(name) end end return result end |
- (Object) option(*declaration, &block) DSL
Declare that this app can take a specific option, and provide the code to do so. See ActionBuilder#option for details.
43 44 45 |
# File 'lib/puppet/interface/option_manager.rb', line 43 def option(*declaration, &block) add_option Puppet::Interface::OptionBuilder.build(self, *declaration, &block) end |
- (Boolean) option?(name) private
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
98 99 100 |
# File 'lib/puppet/interface/option_manager.rb', line 98 def option?(name) .include? name.to_sym end |
- (Object) options private
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
77 78 79 |
# File 'lib/puppet/interface/option_manager.rb', line 77 def walk_inheritance_tree(, :options) end |
- (Object) walk_inheritance_tree(start, sym) private
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
27 28 29 30 31 32 33 34 35 |
# File 'lib/puppet/interface/option_manager.rb', line 27 def walk_inheritance_tree(start, sym) result = (start ||= []) if self.is_a?(Class) and superclass.respond_to?(sym) result = superclass.send(sym) + result elsif self.class.respond_to?(sym) result = self.class.send(sym) + result end return result end |