#!/usr/bin/env ruby # The command line Restfully client require 'restfully' require 'optparse' require 'logger' require 'pp' # Behaviour of pp in IRB is different on ruby1.9: # * pp(object) returns object#inspect. # * we prefer the behaviour of ruby1.8 where pp returns nil. alias :old_pp :pp def pp(*args) old_pp(*args); nil end logger = Logger.new(STDERR) logger.level = Logger::WARN @options = {"logger" => logger} option_parser = OptionParser.new do |opts| opts.banner = < IRB.conf[:SAVE_HISTORY] = 100 IRB.conf[:HISTORY_FILE] = "#{HOME}/.irb-save-history" # Raises an error on Windows, so disabling it. if RUBY_PLATFORM !~ /(win|w)32$/ module Readline module History LOG = "#{HOME}/.irb-history" def self.write_log(line) File.open(LOG, 'ab') {|f| f << "#{line}\n" } end def self.start_session_log write_log("\n") end end alias :old_readline :readline def readline(*args) ln = old_readline(*args) begin History.write_log(ln) rescue end ln end end Readline::History.start_session_log end ARGV.clear ARGV.concat [ "--readline", "--prompt-mode", "simple" ] IRB.start exit!