Method: Harp::REPL#initialize
- Defined in:
- lib/harp/repl.rb
#initialize(command_manager, options = {}) ⇒ REPL
Returns a new instance of REPL.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/harp/repl.rb', line 13 def initialize(command_manager, ={}) @command_manager = command_manager Readline.completion_proc = self.method(:complete) if [:history_file] limit = [:history_limit] || 100 if File.exist?([:history_file]) string = File.read([:history_file]) string.each_line do |line| Readline::HISTORY << line.chomp end end at_exit do File.open([:history_file], "w") do |f| Readline::HISTORY.to_a.last(limit).each do |line| f.puts line unless line.empty? end end end end end |