Sha256: 1ebc211e764f4a21c3e3bcf0020b3f43acb3ba67a069d92270b717da4456f477
Contents?: true
Size: 1.43 KB
Versions: 6
Compression:
Stored size: 1.43 KB
Contents
# encoding: UTF-8 # require 'watchr' module ::Spontaneous::Cli class Console < ::Thor include Spontaneous::Cli::TaskUtils include Thor::Actions namespace :console default_task :open desc "open", "Gives you console access to the current site" def open(*args) open_console end protected def open_console prepare! :console ARGV.clear ARGV.concat [ "--readline", "--prompt-mode", "simple" ] require 'irb' require 'irb/completion' require 'irb/ext/save-history' history_file = ::Spontaneous.root / ".irb_history" IRB.setup(nil) IRB.conf[:SAVE_HISTORY] = 100 IRB.conf[:HISTORY_FILE] = history_file irb = IRB::Irb.new IRB.conf[:MAIN_CONTEXT] = irb.context irb.context.evaluate((<<-CONTEXT), __LINE__) module Readline module History def self.write_log(line) File.open('#{history_file}', 'ab') {|f| f << "\#{line}\n"} end end alias :old_readline :readline def readline(*args) ln = old_readline(*args) begin History.write_log(ln) unless ln.strip.empty? rescue end ln end end CONTEXT trap("SIGINT") do irb.signal_handle end catch("IRB_EXIT") do irb.eval_input end end end # Console end # ::Spontaneous::Cli
Version data entries
6 entries across 6 versions & 1 rubygems