Search code examples
rubyrake

Asking questions in rake tasks


I have a rake task that is called from another rake task.

In this rake task I need to ask the user for some text input, and then, depending on the answer either continue, or stop everything from continuing (including the calling rake task).

How can I do this?


Solution

  • task :input_test do
      input = ''
      STDOUT.puts "What is the airspeed velocity of a swallow?"
      input = STDIN.gets.chomp
      raise "bah, humbug!" unless input == "an african or european swallow?"
    end
    task :blah_blah => :input_test do 
    end
    

    i think that should work