Created
March 28, 2017 14:59
-
-
Save unak/2000c227eeded71902aa14b39680e923 to your computer and use it in GitHub Desktop.
Show candidate when specified task name is not valid
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
begin | |
require "did_you_mean" | |
module Rake::TaskManager | |
def [](task_name, scopes=nil) | |
task_name = task_name.to_s | |
self.lookup(task_name, scopes) or | |
enhance_with_matching_rule(task_name) or | |
synthesize_file_task(task_name) or | |
(STDERR.puts "Don't know how to build task '#{task_name}' (see --tasks)"; | |
candidates = DidYouMean::SpellChecker.new(dictionary: @tasks.keys).correct(task_name); | |
STDERR.puts "Did you mean? " + candidates.join(', ') unless candidates.empty?; | |
exit 1) | |
end | |
end | |
rescue LoadError | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment