35 lines
556 B
Ruby
Raw Normal View History

2020-10-10 14:16:11 +02:00
# typed: true
# frozen_string_literal: true
require "irb"
# @private
module IRB
2020-09-20 05:57:37 +02:00
def self.parse_opts(argv: nil); end
2020-09-20 05:57:37 +02:00
def self.start_within(binding)
unless @setup_done
setup(nil, argv: [])
@setup_done = true
end
2020-09-20 05:57:37 +02:00
workspace = WorkSpace.new(binding)
irb = Irb.new(workspace)
2020-09-20 05:57:37 +02:00
@CONF[:IRB_RC]&.call(irb.context)
@CONF[:MAIN_CONTEXT] = irb.context
2015-03-10 23:25:31 -04:00
2020-09-20 05:57:37 +02:00
trap("SIGINT") do
irb.signal_handle
end
2020-09-20 05:57:37 +02:00
begin
catch(:IRB_EXIT) do
irb.eval_input
end
2020-09-20 05:57:37 +02:00
ensure
irb_at_exit
end
2020-09-20 05:57:37 +02:00
end
end