diff --git a/lib/thor/error.rb b/lib/thor/error.rb index c7c28590..893b135e 100644 --- a/lib/thor/error.rb +++ b/lib/thor/error.rb @@ -102,9 +102,14 @@ class MalformattedArgumentError < InvocationError end if Correctable - DidYouMean::SPELL_CHECKERS.merge!( - 'Thor::UndefinedCommandError' => UndefinedCommandError::SpellChecker, - 'Thor::UnknownArgumentError' => UnknownArgumentError::SpellChecker - ) + 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