#!/usr/bin/env ruby require 'bundler' require 'readline' require 'shellwords' begin Bundler.require(:default, (ENV['RAILS_ENV'] || 'development')) rescue Bundler::GemfileNotFound => e puts "Gemfile Not Found, executing IRB instead" exec("irb") end child = nil Signal.trap("INT") do unless child puts "Skip is terminating..." exit(0) end end while args = Readline.readline("skip> ", true) do ARGV.clear ARGV.push(*Shellwords.split(args)) exec = ARGV.shift time = Time.now child = fork do case exec when 'rails' load './script/rails' when 'rake' require 'rake' Rake.application.run when 'ruby' Skip.setup_ruby file = ARGV.shift load file end end puts "Waiting for child #{child}" Process.waitpid(child) puts "Done in #{(Time.now - time).to_f}" child = nil end puts "Terminated"