Method: QB::Options.add

Defined in:
lib/qb/options.rb

.add(opts, options, role, include_path = []) ⇒ Object

Add the options from a role to the OptionParser

Parameters:

  • opts (OptionParser)

    The option parser to add options to.



137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
# File 'lib/qb/options.rb', line 137

def self.add opts, options, role, include_path = []
  QB.debug "adding options", "role" => role
  
  role.option_metas.each do |option_meta|
    if option_meta.key? 'include'
      include_role opts, options, option_meta, include_path
      
    else
      # create an option
      option = Option.new role, option_meta, include_path
      
      option.option_parser_add opts, included: !include_path.empty?
      
      options[option.cli_name] = option
    end
  end # each var
end