summaryrefslogtreecommitdiff
path: root/lib/bundler/vendor/thor/lib/thor/parser/options.rb
diff options
context:
space:
mode:
authorHiroshi SHIBATA <hsbt@ruby-lang.org>2019-11-13 07:57:02 +0900
committerSHIBATA Hiroshi <hsbt@ruby-lang.org>2019-11-13 10:19:51 +0900
commitbb9ecd026a6cadd5d0f85ac061649216806ed935 (patch)
tree237975b9702a837fd0a8d24575f1edadb4d773d0 /lib/bundler/vendor/thor/lib/thor/parser/options.rb
parent00d56bdf66a3aeaadbc84196aacbd8d4e698cf79 (diff)
Merge Bundler 2.1.0.pre3 released version
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/2674
Diffstat (limited to 'lib/bundler/vendor/thor/lib/thor/parser/options.rb')
-rw-r--r--lib/bundler/vendor/thor/lib/thor/parser/options.rb16
1 files changed, 13 insertions, 3 deletions
diff --git a/lib/bundler/vendor/thor/lib/thor/parser/options.rb b/lib/bundler/vendor/thor/lib/thor/parser/options.rb
index 179f4fa015..6d1342ee3c 100644
--- a/lib/bundler/vendor/thor/lib/thor/parser/options.rb
+++ b/lib/bundler/vendor/thor/lib/thor/parser/options.rb
@@ -97,7 +97,8 @@ class Bundler::Thor
switch = normalize_switch(switch)
option = switch_option(switch)
- @assigns[option.human_name] = parse_peek(switch, option)
+ result = parse_peek(switch, option)
+ assign_result!(option, result)
elsif @stop_on_unknown
@parsing_options = false
@extra << shifted
@@ -132,6 +133,15 @@ class Bundler::Thor
protected
+ def assign_result!(option, result)
+ if option.repeatable && option.type == :hash
+ (@assigns[option.human_name] ||= {}).merge!(result)
+ elsif option.repeatable
+ (@assigns[option.human_name] ||= []) << result
+ else
+ @assigns[option.human_name] = result
+ end
+ end
# Check if the current value in peek is a registered switch.
#
# Two booleans are returned. The first is true if the current value
@@ -161,7 +171,7 @@ class Bundler::Thor
end
def switch?(arg)
- switch_option(normalize_switch(arg))
+ !switch_option(normalize_switch(arg)).nil?
end
def switch_option(arg)
@@ -194,7 +204,7 @@ class Bundler::Thor
shift
false
else
- !no_or_skip?(switch)
+ @switches.key?(switch) || !no_or_skip?(switch)
end
else
@switches.key?(switch) || !no_or_skip?(switch)