diff options
author | David RodrÃguez <deivid.rodriguez@riseup.net> | 2019-09-26 16:34:30 +0200 |
---|---|---|
committer | David RodrÃguez <deivid.rodriguez@riseup.net> | 2019-11-06 17:00:07 +0100 |
commit | d3eb553dfacb4b1a4872277e0a0aaaf31315f393 (patch) | |
tree | 310baaef6ab03598e6aaca5b686dd46145b589f6 | |
parent | 6db8b232b96ac4a057f6ad5488efc9ac5c2a365f (diff) | |
download | bundler-d3eb553dfacb4b1a4872277e0a0aaaf31315f393.tar.gz |
Bump again
-rw-r--r-- | lib/bundler/vendor/thor/lib/thor.rb | 6 | ||||
-rw-r--r-- | lib/bundler/vendor/thor/lib/thor/actions.rb | 1 | ||||
-rw-r--r-- | lib/bundler/vendor/thor/lib/thor/actions/directory.rb | 22 | ||||
-rw-r--r-- | lib/bundler/vendor/thor/lib/thor/actions/file_manipulation.rb | 6 | ||||
-rw-r--r-- | lib/bundler/vendor/thor/lib/thor/base.rb | 2 | ||||
-rw-r--r-- | lib/bundler/vendor/thor/lib/thor/command.rb | 32 | ||||
-rw-r--r-- | lib/bundler/vendor/thor/lib/thor/invocation.rb | 1 | ||||
-rw-r--r-- | lib/bundler/vendor/thor/lib/thor/parser/option.rb | 14 | ||||
-rw-r--r-- | lib/bundler/vendor/thor/lib/thor/parser/options.rb | 12 |
9 files changed, 55 insertions, 41 deletions
diff --git a/lib/bundler/vendor/thor/lib/thor.rb b/lib/bundler/vendor/thor/lib/thor.rb index 395fad28eb..97c58b39af 100644 --- a/lib/bundler/vendor/thor/lib/thor.rb +++ b/lib/bundler/vendor/thor/lib/thor.rb @@ -175,7 +175,7 @@ class Bundler::Thor handle_no_command_error(meth) unless command shell.say "Usage:" - shell.say " #{banner(command)}" + shell.say " #{banner(command).split("\n").join("\n ")}" shell.say class_options_help(shell, nil => command.options.values) if command.long_description @@ -398,7 +398,9 @@ class Bundler::Thor # the namespace should be displayed as arguments. # def banner(command, namespace = nil, subcommand = false) - "#{basename} #{command.formatted_usage(self, $thor_runner, subcommand)}" + command.formatted_usage(self, $thor_runner, subcommand).split("\n").map do |formatted_usage| + "#{basename} #{formatted_usage}" + end.join("\n") end def baseclass #:nodoc: diff --git a/lib/bundler/vendor/thor/lib/thor/actions.rb b/lib/bundler/vendor/thor/lib/thor/actions.rb index 5681d5a7c6..39ce67e142 100644 --- a/lib/bundler/vendor/thor/lib/thor/actions.rb +++ b/lib/bundler/vendor/thor/lib/thor/actions.rb @@ -12,6 +12,7 @@ class Bundler::Thor attr_accessor :behavior def self.included(base) #:nodoc: + super(base) base.extend ClassMethods end diff --git a/lib/bundler/vendor/thor/lib/thor/actions/directory.rb b/lib/bundler/vendor/thor/lib/thor/actions/directory.rb index 03c97bf630..d37327a139 100644 --- a/lib/bundler/vendor/thor/lib/thor/actions/directory.rb +++ b/lib/bundler/vendor/thor/lib/thor/actions/directory.rb @@ -56,7 +56,7 @@ class Bundler::Thor attr_reader :source def initialize(base, source, destination = nil, config = {}, &block) - @source = File.expand_path(base.find_in_source_paths(source.to_s)) + @source = File.expand_path(Dir[Util.escape_globs(base.find_in_source_paths(source.to_s))].first) @block = block super(base, destination, {:recursive => true}.merge(config)) end @@ -96,22 +96,12 @@ class Bundler::Thor end end - if RUBY_VERSION < "2.0" - def file_level_lookup(previous_lookup) - File.join(previous_lookup, "{*,.[a-z]*}") - end - - def files(lookup) - Dir[lookup] - end - else - def file_level_lookup(previous_lookup) - File.join(previous_lookup, "*") - end + def file_level_lookup(previous_lookup) + File.join(previous_lookup, "*") + end - def files(lookup) - Dir.glob(lookup, File::FNM_DOTMATCH) - end + def files(lookup) + Dir.glob(lookup, File::FNM_DOTMATCH) end end end diff --git a/lib/bundler/vendor/thor/lib/thor/actions/file_manipulation.rb b/lib/bundler/vendor/thor/lib/thor/actions/file_manipulation.rb index b282fc42bd..afdbd53dd0 100644 --- a/lib/bundler/vendor/thor/lib/thor/actions/file_manipulation.rb +++ b/lib/bundler/vendor/thor/lib/thor/actions/file_manipulation.rb @@ -80,14 +80,14 @@ class Bundler::Thor config = args.last.is_a?(Hash) ? args.pop : {} destination = args.first - if source =~ %r{^https?\://} + render = if source =~ %r{^https?\://} require "open-uri" + URI.send(:open, source) { |input| input.binmode.read } else source = File.expand_path(find_in_source_paths(source.to_s)) + open(source) { |input| input.binmode.read } end - render = open(source) { |input| input.binmode.read } - destination ||= if block_given? block.arity == 1 ? yield(render) : yield else diff --git a/lib/bundler/vendor/thor/lib/thor/base.rb b/lib/bundler/vendor/thor/lib/thor/base.rb index 907229f200..6089fd3dc4 100644 --- a/lib/bundler/vendor/thor/lib/thor/base.rb +++ b/lib/bundler/vendor/thor/lib/thor/base.rb @@ -502,7 +502,7 @@ class Bundler::Thor msg = "ERROR: \"#{basename} #{name}\" was called with ".dup msg << "no arguments" if args.empty? msg << "arguments " << args.inspect unless args.empty? - msg << "\nUsage: #{banner(command).inspect}" + msg << "\nUsage: \"#{banner(command).split("\n").join("\"\n \"")}\"" raise InvocationError, msg end diff --git a/lib/bundler/vendor/thor/lib/thor/command.rb b/lib/bundler/vendor/thor/lib/thor/command.rb index c9adfef802..040c971c0c 100644 --- a/lib/bundler/vendor/thor/lib/thor/command.rb +++ b/lib/bundler/vendor/thor/lib/thor/command.rb @@ -49,24 +49,32 @@ class Bundler::Thor formatted ||= "".dup - # Add usage with required arguments - formatted << if klass && !klass.arguments.empty? - usage.to_s.gsub(/^#{name}/) do |match| - match << " " << klass.arguments.map(&:usage).compact.join(" ") - end - else - usage.to_s - end + Array(usage).map do |specific_usage| + formatted_specific_usage = formatted - # Add required options - formatted << " #{required_options}" + formatted_specific_usage += required_arguments_for(klass, specific_usage) - # Strip and go! - formatted.strip + # Add required options + formatted_specific_usage += " #{required_options}" + + # Strip and go! + formatted_specific_usage.strip + end.join("\n") end protected + # Add usage with required arguments + def required_arguments_for(klass, usage) + if klass && !klass.arguments.empty? + usage.to_s.gsub(/^#{name}/) do |match| + match << " " << klass.arguments.map(&:usage).compact.join(" ") + end + else + usage.to_s + end + end + def not_debugging?(instance) !(instance.class.respond_to?(:debugging) && instance.class.debugging) end diff --git a/lib/bundler/vendor/thor/lib/thor/invocation.rb b/lib/bundler/vendor/thor/lib/thor/invocation.rb index 866d2212a7..248a466f8e 100644 --- a/lib/bundler/vendor/thor/lib/thor/invocation.rb +++ b/lib/bundler/vendor/thor/lib/thor/invocation.rb @@ -1,6 +1,7 @@ class Bundler::Thor module Invocation def self.included(base) #:nodoc: + super(base) base.extend ClassMethods end diff --git a/lib/bundler/vendor/thor/lib/thor/parser/option.rb b/lib/bundler/vendor/thor/lib/thor/parser/option.rb index 85169b56c8..0ddd472b43 100644 --- a/lib/bundler/vendor/thor/lib/thor/parser/option.rb +++ b/lib/bundler/vendor/thor/lib/thor/parser/option.rb @@ -1,17 +1,18 @@ class Bundler::Thor class Option < Argument #:nodoc: - attr_reader :aliases, :group, :lazy_default, :hide + attr_reader :aliases, :group, :lazy_default, :hide, :repeatable VALID_TYPES = [:boolean, :numeric, :hash, :array, :string] def initialize(name, options = {}) @check_default_type = options[:check_default_type] options[:required] = false unless options.key?(:required) + @repeatable = options.fetch(:repeatable, false) super - @lazy_default = options[:lazy_default] - @group = options[:group].to_s.capitalize if options[:group] - @aliases = Array(options[:aliases]) - @hide = options[:hide] + @lazy_default = options[:lazy_default] + @group = options[:group].to_s.capitalize if options[:group] + @aliases = Array(options[:aliases]) + @hide = options[:hide] end # This parse quick options given as method_options. It makes several @@ -128,7 +129,8 @@ class Bundler::Thor @default.class.name.downcase.to_sym end - raise ArgumentError, "Expected #{@type} default value for '#{switch_name}'; got #{@default.inspect} (#{default_type})" unless default_type == @type + expected_type = (@repeatable && @type != :hash) ? :array : @type + raise ArgumentError, "Expected #{expected_type} default value for '#{switch_name}'; got #{@default.inspect} (#{default_type})" unless default_type == expected_type end def dasherized? diff --git a/lib/bundler/vendor/thor/lib/thor/parser/options.rb b/lib/bundler/vendor/thor/lib/thor/parser/options.rb index 179f4fa015..938585786a 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 |