Update vendored thor to 1.3.2

This commit is contained in:
David Rodríguez 2024-11-11 20:45:08 +01:00 committed by Hiroshi SHIBATA
parent 99c35edae1
commit 7ece47e0de
12 changed files with 48 additions and 46 deletions

View File

@ -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<String>:: 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.

View File

@ -10,7 +10,6 @@ class Bundler::Thor
# destination<String>:: the relative path to the destination root.
# config<Hash>:: 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<String>:: 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

View File

@ -211,6 +211,17 @@ class Bundler::Thor::Group
raise error, msg
end
# Checks if a specified command exists.
#
# ==== Parameters
# command_name<String>:: 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.

View File

@ -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

View File

@ -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

View File

@ -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?

View File

@ -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)

View File

@ -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)

View File

@ -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

View File

@ -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)

View File

@ -1,3 +1,3 @@
class Bundler::Thor
VERSION = "1.3.0"
VERSION = "1.3.2"
end

View File

@ -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"