1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
|
# frozen_string_literal: true
module Byebug
#
# Interface class for command execution from script files.
#
class ScriptInterface < Interface
def initialize(file, verbose = false)
super()
@verbose = verbose
@input = File.open(file)
@output = verbose ? $stdout : StringIO.new
@error = $stderr
end
def read_command(prompt)
readline(prompt, false)
end
def close
input.close
end
def readline(*)
while (result = input.gets)
output.puts "+ #{result}" if @verbose
next if /^\s*#/.match?(result)
return result.chomp
end
end
end
end
|