From 7ece47e0de0f3a22752a4c1b9f7d9466d32d8f0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= Date: Mon, 11 Nov 2024 20:45:08 +0100 Subject: [PATCH] Update vendored thor to 1.3.2 --- lib/bundler/vendor/thor/lib/thor.rb | 11 ++++++++ .../lib/thor/actions/file_manipulation.rb | 8 +++--- lib/bundler/vendor/thor/lib/thor/group.rb | 11 ++++++++ .../vendor/thor/lib/thor/parser/argument.rb | 5 +--- .../vendor/thor/lib/thor/parser/option.rb | 4 +-- .../vendor/thor/lib/thor/parser/options.rb | 3 ++- .../vendor/thor/lib/thor/shell/basic.rb | 18 ++++++------- .../vendor/thor/lib/thor/shell/html.rb | 2 +- .../thor/lib/thor/shell/table_printer.rb | 26 ++++--------------- lib/bundler/vendor/thor/lib/thor/util.rb | 2 +- lib/bundler/vendor/thor/lib/thor/version.rb | 2 +- tool/bundler/vendor_gems.rb | 2 +- 12 files changed, 48 insertions(+), 46 deletions(-) diff --git a/lib/bundler/vendor/thor/lib/thor.rb b/lib/bundler/vendor/thor/lib/thor.rb index 627722164f..bfd9f5c914 100644 --- a/lib/bundler/vendor/thor/lib/thor.rb +++ b/lib/bundler/vendor/thor/lib/thor.rb @@ -439,6 +439,17 @@ class Bundler::Thor command && disable_required_check.include?(command.name.to_sym) end + # Checks if a specified command exists. + # + # ==== Parameters + # command_name:: The name of the command to check for existence. + # + # ==== Returns + # Boolean:: +true+ if the command exists, +false+ otherwise. + def command_exists?(command_name) #:nodoc: + commands.keys.include?(normalize_command_name(command_name)) + end + protected # Returns this class exclusive options array set. 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 80a0255996..bccfbb6b85 100644 --- a/lib/bundler/vendor/thor/lib/thor/actions/file_manipulation.rb +++ b/lib/bundler/vendor/thor/lib/thor/actions/file_manipulation.rb @@ -10,7 +10,6 @@ class Bundler::Thor # destination:: the relative path to the destination root. # config:: give :verbose => false to not log the status, and # :mode => :preserve, to preserve the file mode from the source. - # # ==== Examples # @@ -275,9 +274,8 @@ class Bundler::Thor end end - # Uncomment all lines matching a given regex. It will leave the space - # which existed before the comment hash in tact but will remove any spacing - # between the comment hash and the beginning of the line. + # Uncomment all lines matching a given regex. Preserves indentation before + # the comment hash and removes the hash and any immediate following space. # # ==== Parameters # path:: path of the file to be changed @@ -291,7 +289,7 @@ class Bundler::Thor def uncomment_lines(path, flag, *args) flag = flag.respond_to?(:source) ? flag.source : flag - gsub_file(path, /^(\s*)#[[:blank:]]*(.*#{flag})/, '\1\2', *args) + gsub_file(path, /^(\s*)#[[:blank:]]?(.*#{flag})/, '\1\2', *args) end # Comment all lines matching a given regex. It will leave the space diff --git a/lib/bundler/vendor/thor/lib/thor/group.rb b/lib/bundler/vendor/thor/lib/thor/group.rb index 7ea11e8f93..30bc311294 100644 --- a/lib/bundler/vendor/thor/lib/thor/group.rb +++ b/lib/bundler/vendor/thor/lib/thor/group.rb @@ -211,6 +211,17 @@ class Bundler::Thor::Group raise error, msg end + # Checks if a specified command exists. + # + # ==== Parameters + # command_name:: The name of the command to check for existence. + # + # ==== Returns + # Boolean:: +true+ if the command exists, +false+ otherwise. + def command_exists?(command_name) #:nodoc: + commands.keys.include?(command_name) + end + protected # The method responsible for dispatching given the args. diff --git a/lib/bundler/vendor/thor/lib/thor/parser/argument.rb b/lib/bundler/vendor/thor/lib/thor/parser/argument.rb index b9e94e4669..ee9db4ad8a 100644 --- a/lib/bundler/vendor/thor/lib/thor/parser/argument.rb +++ b/lib/bundler/vendor/thor/lib/thor/parser/argument.rb @@ -26,10 +26,7 @@ class Bundler::Thor def print_default if @type == :array and @default.is_a?(Array) - @default.map { |x| - p = x.gsub('"','\\"') - "\"#{p}\"" - }.join(" ") + @default.map(&:dump).join(" ") else @default end diff --git a/lib/bundler/vendor/thor/lib/thor/parser/option.rb b/lib/bundler/vendor/thor/lib/thor/parser/option.rb index c6af4e1e87..72617c7e34 100644 --- a/lib/bundler/vendor/thor/lib/thor/parser/option.rb +++ b/lib/bundler/vendor/thor/lib/thor/parser/option.rb @@ -89,8 +89,8 @@ class Bundler::Thor sample = "[#{sample}]".dup unless required? - if boolean? - sample << ", [#{dasherize('no-' + human_name)}]" unless (name == "force") || name.match(/\Ano[\-_]/) + if boolean? && name != "force" && !name.match(/\A(no|skip)[\-_]/) + sample << ", [#{dasherize('no-' + human_name)}], [#{dasherize('skip-' + human_name)}]" end aliases_for_usage.ljust(padding) + sample diff --git a/lib/bundler/vendor/thor/lib/thor/parser/options.rb b/lib/bundler/vendor/thor/lib/thor/parser/options.rb index 978e76b132..734f5fe7e3 100644 --- a/lib/bundler/vendor/thor/lib/thor/parser/options.rb +++ b/lib/bundler/vendor/thor/lib/thor/parser/options.rb @@ -250,7 +250,8 @@ class Bundler::Thor @parsing_options end - # Parse boolean values which can be given as --foo=true, --foo or --no-foo. + # Parse boolean values which can be given as --foo=true or --foo for true values, or + # --foo=false, --no-foo or --skip-foo for false values. # def parse_boolean(switch) if current_is_value? diff --git a/lib/bundler/vendor/thor/lib/thor/shell/basic.rb b/lib/bundler/vendor/thor/lib/thor/shell/basic.rb index dc3179e5f3..b3e85733cb 100644 --- a/lib/bundler/vendor/thor/lib/thor/shell/basic.rb +++ b/lib/bundler/vendor/thor/lib/thor/shell/basic.rb @@ -67,15 +67,15 @@ class Bundler::Thor # Readline. # # ==== Example - # ask("What is your name?") + # ask("What is your name?") # - # ask("What is the planet furthest from the sun?", :default => "Pluto") + # ask("What is the planet furthest from the sun?", :default => "Neptune") # - # ask("What is your favorite Neopolitan flavor?", :limited_to => ["strawberry", "chocolate", "vanilla"]) + # ask("What is your favorite Neopolitan flavor?", :limited_to => ["strawberry", "chocolate", "vanilla"]) # - # ask("What is your password?", :echo => false) + # ask("What is your password?", :echo => false) # - # ask("Where should the file be saved?", :path => true) + # ask("Where should the file be saved?", :path => true) # def ask(statement, *args) options = args.last.is_a?(Hash) ? args.pop : {} @@ -93,7 +93,7 @@ class Bundler::Thor # are passed straight to puts (behavior got from Highline). # # ==== Example - # say("I know you knew that.") + # say("I know you knew that.") # def say(message = "", color = nil, force_new_line = (message.to_s !~ /( |\t)\Z/)) return if quiet? @@ -110,7 +110,7 @@ class Bundler::Thor # are passed straight to puts (behavior got from Highline). # # ==== Example - # say_error("error: something went wrong") + # say_error("error: something went wrong") # def say_error(message = "", color = nil, force_new_line = (message.to_s !~ /( |\t)\Z/)) return if quiet? @@ -143,14 +143,14 @@ class Bundler::Thor stdout.flush end - # Make a question the to user and returns true if the user replies "y" or + # Asks the user a question and returns true if the user replies "y" or # "yes". # def yes?(statement, color = nil) !!(ask(statement, color, add_to_history: false) =~ is?(:yes)) end - # Make a question the to user and returns true if the user replies "n" or + # Asks the user a question and returns true if the user replies "n" or # "no". # def no?(statement, color = nil) diff --git a/lib/bundler/vendor/thor/lib/thor/shell/html.rb b/lib/bundler/vendor/thor/lib/thor/shell/html.rb index 0277b882b7..a0a8520e5c 100644 --- a/lib/bundler/vendor/thor/lib/thor/shell/html.rb +++ b/lib/bundler/vendor/thor/lib/thor/shell/html.rb @@ -64,7 +64,7 @@ class Bundler::Thor # Ask something to the user and receives a response. # # ==== Example - # ask("What is your name?") + # ask("What is your name?") # # TODO: Implement #ask for Bundler::Thor::Shell::HTML def ask(statement, color = nil) diff --git a/lib/bundler/vendor/thor/lib/thor/shell/table_printer.rb b/lib/bundler/vendor/thor/lib/thor/shell/table_printer.rb index 525f9ce5bb..dee3614753 100644 --- a/lib/bundler/vendor/thor/lib/thor/shell/table_printer.rb +++ b/lib/bundler/vendor/thor/lib/thor/shell/table_printer.rb @@ -102,33 +102,17 @@ class Bundler::Thor def truncate(string) return string unless @truncate - as_unicode do - chars = string.chars.to_a - if chars.length <= @truncate - chars.join - else - chars[0, @truncate - 3 - @indent].join + "..." - end + chars = string.chars.to_a + if chars.length <= @truncate + chars.join + else + chars[0, @truncate - 3 - @indent].join + "..." end end def indentation " " * @indent end - - if "".respond_to?(:encode) - def as_unicode - yield - end - else - def as_unicode - old = $KCODE # rubocop:disable Style/GlobalVars - $KCODE = "U" # rubocop:disable Style/GlobalVars - yield - ensure - $KCODE = old # rubocop:disable Style/GlobalVars - end - end end end end diff --git a/lib/bundler/vendor/thor/lib/thor/util.rb b/lib/bundler/vendor/thor/lib/thor/util.rb index 68916daf2e..cd8f9ece87 100644 --- a/lib/bundler/vendor/thor/lib/thor/util.rb +++ b/lib/bundler/vendor/thor/lib/thor/util.rb @@ -133,7 +133,7 @@ class Bundler::Thor *pieces, command = namespace.split(":") namespace = pieces.join(":") namespace = "default" if namespace.empty? - klass = Bundler::Thor::Base.subclasses.detect { |thor| thor.namespace == namespace && thor.commands.keys.include?(command) } + klass = Bundler::Thor::Base.subclasses.detect { |thor| thor.namespace == namespace && thor.command_exists?(command) } end unless klass # look for a Bundler::Thor::Group with the right name klass = Bundler::Thor::Util.find_by_namespace(namespace) diff --git a/lib/bundler/vendor/thor/lib/thor/version.rb b/lib/bundler/vendor/thor/lib/thor/version.rb index 1fb00017ed..cd7b4f060e 100644 --- a/lib/bundler/vendor/thor/lib/thor/version.rb +++ b/lib/bundler/vendor/thor/lib/thor/version.rb @@ -1,3 +1,3 @@ class Bundler::Thor - VERSION = "1.3.0" + VERSION = "1.3.2" end diff --git a/tool/bundler/vendor_gems.rb b/tool/bundler/vendor_gems.rb index be8e7daa4e..7103f02bb2 100644 --- a/tool/bundler/vendor_gems.rb +++ b/tool/bundler/vendor_gems.rb @@ -12,6 +12,6 @@ gem "pub_grub", github: "jhawthorn/pub_grub" gem "resolv", "0.5.0" gem "securerandom", "0.3.2" gem "timeout", "0.4.2" -gem "thor", "1.3.0" +gem "thor", "1.3.2" gem "tsort", "0.2.0" gem "uri", "1.0.1"