Class: Picky::Console
Overview
Handles the IRB console for Picky.
Class Method Summary collapse
Class Method Details
.start(args = ARGV) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/picky/console.rb', line 10 def self.start args = ARGV irb = 'irb' require 'optparse' = { :sandbox => false, :irb => irb } OptionParser.new do |opt| opt. = "Usage: console [environment] [options]" opt.on("--irb=[#{irb}]", 'Invoke a different irb.') { |v| [:irb] = v } opt.parse!(args) end libs = " -r irb/completion" libs << %( -r "#{File.expand_path('../../picky.rb', __FILE__)}" ) mapping = { 'p' => 'production', 'd' => 'development', 't' => 'test' } given_env = args.first ENV['PICKY_ENV'] = mapping[given_env] || given_env || ENV['PICKY_ENV'] || 'development' puts "Use \x1b[1;30mPicky::Loader.load_application\x1b[m to load app." puts "Use \x1b[1;30mPicky::Indexes.load\x1b[m after that to load indexes." puts "Copy the following line to do just that:" puts "\x1b[1;30mPicky::Loader.load_application; Picky::Indexes.load; p\x1b[m" exec "#{options[:irb]} #{libs} --simple-prompt" end |