Skip to content

Instantly share code, notes, and snippets.

@ayosec
Created October 8, 2010 11:47
Show Gist options
  • Save ayosec/616665 to your computer and use it in GitHub Desktop.
Save ayosec/616665 to your computer and use it in GitHub Desktop.
#!/usr/bin/ruby
begin
require "readline"
rescue LoadError
STDERR.puts "No readline found"
end
load "Rakefile"
Rake::Task["environment"].invoke
last_input = ARGV.first || "test"
begin
while true
prompt = "Task [#{last_input}]> "
input = if defined?(Readline)
Readline.readline(prompt, true)
else
STDOUT.print
input = STDIN.readline.strip
end
if input.blank?
input = [last_input]
else
last_input = input
end
Process.waitpid(fork do
ActiveRecord::Base.connection.reconnect! rescue STDERR.puts("No reconnect: #$!")
tasks = []
input.split.each do |item|
if item.include?("=")
name, value = item.split("=", 2)
ENV[name] = value
else
tasks << item
end
end
tasks.each do |task_name|
Rake::Task[task_name].invoke
end
end)
end
rescue Interrupt, EOFError
puts "^C"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment