summaryrefslogtreecommitdiff
path: root/lib/bundler/vendor/thor/lib/thor/error.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/bundler/vendor/thor/lib/thor/error.rb')
-rw-r--r--lib/bundler/vendor/thor/lib/thor/error.rb36
1 files changed, 16 insertions, 20 deletions
diff --git a/lib/bundler/vendor/thor/lib/thor/error.rb b/lib/bundler/vendor/thor/lib/thor/error.rb
index 7d57129b83..928646e501 100644
--- a/lib/bundler/vendor/thor/lib/thor/error.rb
+++ b/lib/bundler/vendor/thor/lib/thor/error.rb
@@ -1,18 +1,15 @@
class Bundler::Thor
Correctable = if defined?(DidYouMean::SpellChecker) && defined?(DidYouMean::Correctable) # rubocop:disable Naming/ConstantName
- # In order to support versions of Ruby that don't have keyword
- # arguments, we need our own spell checker class that doesn't take key
- # words. Even though this code wouldn't be hit because of the check
- # above, it's still necessary because the interpreter would otherwise be
- # unable to parse the file.
- class NoKwargSpellChecker < DidYouMean::SpellChecker # :nodoc:
- def initialize(dictionary)
- @dictionary = dictionary
- end
- end
-
- DidYouMean::Correctable
- end
+ Module.new do
+ def to_s
+ super + DidYouMean.formatter.message_for(corrections)
+ end
+
+ def corrections
+ @corrections ||= self.class.const_get(:SpellChecker).new(self).corrections
+ end
+ end
+ end
# Bundler::Thor::Error is raised when it's caused by wrong usage of thor classes. Those
# errors have their backtrace suppressed and are nicely shown to the user.
@@ -37,7 +34,7 @@ class Bundler::Thor
end
def spell_checker
- NoKwargSpellChecker.new(error.all_commands)
+ DidYouMean::SpellChecker.new(dictionary: error.all_commands)
end
end
@@ -79,7 +76,7 @@ class Bundler::Thor
end
def spell_checker
- @spell_checker ||= NoKwargSpellChecker.new(error.switches)
+ @spell_checker ||= DidYouMean::SpellChecker.new(dictionary: error.switches)
end
end
@@ -101,10 +98,9 @@ class Bundler::Thor
class MalformattedArgumentError < InvocationError
end
- if Correctable
- DidYouMean::SPELL_CHECKERS.merge!(
- 'Bundler::Thor::UndefinedCommandError' => UndefinedCommandError::SpellChecker,
- 'Bundler::Thor::UnknownArgumentError' => UnknownArgumentError::SpellChecker
- )
+ class ExclusiveArgumentError < InvocationError
+ end
+
+ class AtLeastOneRequiredArgumentError < InvocationError
end
end