25 lines
486 B
Ruby
Raw Permalink Normal View History

2025-06-17 16:33:58 +01:00
# typed: strict
# frozen_string_literal: true
require "irb"
module IRB
2025-06-17 16:33:58 +01:00
sig { params(binding: Binding).void }
2020-09-20 05:57:37 +02:00
def self.start_within(binding)
2024-08-03 01:16:58 +01:00
old_stdout_sync = $stdout.sync
$stdout.sync = true
2025-06-17 16:33:58 +01:00
@setup_done ||= T.let(false, T.nilable(T::Boolean))
2020-09-20 05:57:37 +02:00
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)
2024-08-03 01:16:58 +01:00
irb.run(conf)
ensure
$stdout.sync = old_stdout_sync
2020-09-20 05:57:37 +02:00
end
end