mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00
25 lines
486 B
Ruby
25 lines
486 B
Ruby
# typed: strict
|
|
# frozen_string_literal: true
|
|
|
|
require "irb"
|
|
|
|
module IRB
|
|
sig { params(binding: Binding).void }
|
|
def self.start_within(binding)
|
|
old_stdout_sync = $stdout.sync
|
|
$stdout.sync = true
|
|
|
|
@setup_done ||= T.let(false, T.nilable(T::Boolean))
|
|
unless @setup_done
|
|
setup(nil, argv: [])
|
|
@setup_done = true
|
|
end
|
|
|
|
workspace = WorkSpace.new(binding)
|
|
irb = Irb.new(workspace)
|
|
irb.run(conf)
|
|
ensure
|
|
$stdout.sync = old_stdout_sync
|
|
end
|
|
end
|