Method: Thor::Options#initialize
- Defined in:
- lib/thor/parser/options.rb
permalink #initialize(hash_options = {}, defaults = {}, stop_on_unknown = false, disable_required_check = false, relations = {}) ⇒ Options
Takes a hash of Thor::Option and a hash with defaults.
If stop_on_unknown
is true, #parse will stop as soon as it encounters an unknown option or a regular argument.
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/thor/parser/options.rb', line 32 def initialize( = {}, defaults = {}, stop_on_unknown = false, disable_required_check = false, relations = {}) @stop_on_unknown = stop_on_unknown @exclusives = (relations[:exclusive_option_names] || []).select{|array| !array.empty?} @at_least_ones = (relations[:at_least_one_option_names] || []).select{|array| !array.empty?} @disable_required_check = disable_required_check = .values super() # Add defaults defaults.each do |key, value| @assigns[key.to_s] = value @non_assigned_required.delete([key]) end @shorts = {} @switches = {} @extra = [] @stopped_parsing_after_extra_index = nil @is_treated_as_value = false .each do |option| @switches[option.switch_name] = option option.aliases.each do |name| @shorts[name] ||= option.switch_name end end end |