Skip to content

Instantly share code, notes, and snippets.

@unak
Created March 28, 2017 14:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save unak/2000c227eeded71902aa14b39680e923 to your computer and use it in GitHub Desktop.
Save unak/2000c227eeded71902aa14b39680e923 to your computer and use it in GitHub Desktop.
Show candidate when specified task name is not valid
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