josevalim-thor 0.10.14 → 0.10.15

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/lib/thor/base.rb +1 -1
  2. data/lib/thor/options.rb +9 -15
  3. metadata +1 -1
data/lib/thor/base.rb CHANGED
@@ -362,7 +362,7 @@ class Thor
362
362
  end
363
363
 
364
364
  thor_options.each do |key, option|
365
- next if option.argument? || option.default.nil?
365
+ next if option.argument? || option.default.nil? || options.key?(option.human_name.to_s)
366
366
  options[option.human_name.to_s] ||= option.default
367
367
  end
368
368
  end
data/lib/thor/options.rb CHANGED
@@ -93,11 +93,11 @@ class Thor
93
93
  next if option.nil? || option.argument?
94
94
 
95
95
  check_requirement!(switch, option)
96
- parse_option(switch, option, @options)
96
+ @options[option.human_name] = parse_option(switch, option)
97
97
  else
98
98
  unless @non_assigned_arguments.empty?
99
99
  argument = @non_assigned_arguments.shift
100
- parse_option(argument.switch_name, argument, @options)
100
+ @options[argument.human_name] = parse_option(argument.switch_name, argument)
101
101
  @arguments << @options.delete(argument.human_name)
102
102
  else
103
103
  @trailing << shift
@@ -164,8 +164,8 @@ class Thor
164
164
  # value to it. At the end, remove the option from the array where non
165
165
  # assigned requireds are kept.
166
166
  #
167
- def parse_option(switch, option, hash)
168
- human_name = option.human_name
167
+ def parse_option(switch, option)
168
+ @non_assigned_required.delete(option)
169
169
 
170
170
  type = if option.type == :default
171
171
  peek.nil? || peek.to_s =~ /^-/ ? :boolean : :string
@@ -175,22 +175,16 @@ class Thor
175
175
 
176
176
  case type
177
177
  when :boolean
178
- if !@switches.key?(switch) && switch =~ /^--(no|skip)-([-\w]+)$/
179
- hash[$2] = false
180
- else
181
- hash[human_name] = true
182
- end
178
+ @switches.key?(switch) || switch !~ /^--(no|skip)-([-\w]+)$/
183
179
  when :string
184
- hash[human_name] = shift
180
+ shift
185
181
  when :numeric
186
- hash[human_name] = parse_numeric(switch)
182
+ parse_numeric(switch)
187
183
  when :hash
188
- hash[human_name] = parse_hash
184
+ parse_hash
189
185
  when :array
190
- hash[human_name] = parse_array
186
+ parse_array
191
187
  end
192
-
193
- @non_assigned_required.delete(option)
194
188
  end
195
189
 
196
190
  # Runs through the argument array getting strings that contains ":" and
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: josevalim-thor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.14
4
+ version: 0.10.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yehuda Katz