diff options
Diffstat (limited to 'lib/bundler/vendor/thor/lib/thor/parser/options.rb')
-rw-r--r-- | lib/bundler/vendor/thor/lib/thor/parser/options.rb | 16 |
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) |