# module Puppet::Interface::OptionManager

This class is not actually public API, but the method {Puppet::Interface::OptionManager#option option} is public when used as part of the Faces DSL (i.e. from within a {Puppet::Interface.define define} block). @api public

### Public Instance Methods

add_option(option) click to toggle source

@api private

    # 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.
      @options      ||= []
      @options_hash ||= {}

      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

      @options << option.name

      option.aliases.each do |name|
        @options_hash[name] = option
      end

      return option
    end

all_display_global_options() click to toggle source

    # File lib/puppet/interface/option_manager.rb, line 22
    def all_display_global_options
      walk_inheritance_tree(@display_global_options, :all_display_global_options)
    end

display_global_option(*args)
Alias for: display_global_options
display_global_options(*args) click to toggle source

@api private

    # File lib/puppet/interface/option_manager.rb, line 11
    def display_global_options(*args)
      @display_global_options ||= []
      [args].flatten.each do |refopt|
        raise ArgumentError, "Global option #{refopt} does not exist in Puppet.settings" unless Puppet.settings.include? refopt
        @display_global_options << refopt if refopt
      end
      @display_global_options.uniq!
      @display_global_options
    end

Also aliased as: display_global_option
get_option(name, with_inherited_options = true) click to toggle source

@api private

    # File lib/puppet/interface/option_manager.rb, line 82
    def get_option(name, with_inherited_options = true)
      @options_hash ||= {}

      result = @options_hash[name.to_sym]
      if result.nil? and with_inherited_options 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

option(*declaration, &block) click to toggle source

Declare that this app can take a specific option, and provide the code to do so. See {Puppet::Interface::ActionBuilder#option} for details.

@api public @dsl Faces

    # File lib/puppet/interface/option_manager.rb, line 43
    def option(*declaration, &block)
      add_option Puppet::Interface::OptionBuilder.build(self, *declaration, &block)
    end

option?(name) click to toggle source

@api private

    # File lib/puppet/interface/option_manager.rb, line 98
    def option?(name)
      options.include? name.to_sym
    end

options() click to toggle source

@api private

    # File lib/puppet/interface/option_manager.rb, line 77
    def options
      walk_inheritance_tree(@options, :options)
    end

walk_inheritance_tree(start, sym) click to toggle source

@api private

    # 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