Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 9 additions & 13 deletions lib/thor/error.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,15 @@ def initialize(dictionary)
end
end

DidYouMean::Correctable
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

# Thor::Error is raised when it's caused by wrong usage of thor classes. Those
Expand Down Expand Up @@ -100,16 +108,4 @@ class RequiredArgumentMissingError < InvocationError

class MalformattedArgumentError < InvocationError
end

if Correctable
if DidYouMean.respond_to?(:correct_error)
DidYouMean.correct_error(Thor::UndefinedCommandError, UndefinedCommandError::SpellChecker)
DidYouMean.correct_error(Thor::UnknownArgumentError, UnknownArgumentError::SpellChecker)
else
DidYouMean::SPELL_CHECKERS.merge!(
'Thor::UndefinedCommandError' => UndefinedCommandError::SpellChecker,
'Thor::UnknownArgumentError' => UnknownArgumentError::SpellChecker
)
end
end
end