Skip to content

Commit f282982

Browse files
committed
Support activating IRB as console with a config
1 parent 50f1a88 commit f282982

File tree

4 files changed

+24
-0
lines changed

4 files changed

+24
-0
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,7 @@ config set no_color true
477477
* `RUBY_DEBUG_NO_RELINE` (`no_reline`): Do not use Reline library (default: false)
478478
* `RUBY_DEBUG_NO_HINT` (`no_hint`): Do not show the hint on the REPL (default: false)
479479
* `RUBY_DEBUG_NO_LINENO` (`no_lineno`): Do not show line numbers (default: false)
480+
* `RUBY_DEBUG_IRB_CONSOLE` (`irb_console`): Use IRB as the console (default: false)
480481

481482
* CONTROL
482483
* `RUBY_DEBUG_SKIP_PATH` (`skip_path`): Skip showing/entering frames for given paths

lib/debug/config.rb

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ module DEBUGGER__
2222
no_reline: ['RUBY_DEBUG_NO_RELINE', "UI: Do not use Reline library", :bool, "false"],
2323
no_hint: ['RUBY_DEBUG_NO_HINT', "UI: Do not show the hint on the REPL", :bool, "false"],
2424
no_lineno: ['RUBY_DEBUG_NO_LINENO', "UI: Do not show line numbers", :bool, "false"],
25+
irb_console: ["RUBY_DEBUG_IRB_CONSOLE", "UI: Use IRB as the console", :bool, "false"],
2526

2627
# control setting
2728
skip_path: ['RUBY_DEBUG_SKIP_PATH', "CONTROL: Skip showing/entering frames for given paths", :path],

lib/debug/session.rb

+5
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,11 @@ def activate ui = nil, on_fork: false
202202
end
203203
@tp_thread_end.enable
204204

205+
if CONFIG[:irb_console] && !CONFIG[:open]
206+
require_relative "irb_integration"
207+
thc.activate_irb_integration
208+
end
209+
205210
# session start
206211
q << true
207212
session_server_main

test/console/irb_test.rb

+17
Original file line numberDiff line numberDiff line change
@@ -41,5 +41,22 @@ def test_irb_command_switches_console_to_irb
4141
type 'q!'
4242
end
4343
end
44+
45+
def test_irb_console_config_activates_irb
46+
ENV["RUBY_DEBUG_IRB_CONSOLE"] = "true"
47+
48+
debug_code(program, remote: false) do
49+
type '123'
50+
assert_line_text 'irb:rdbg(main):002> 123'
51+
type 'irb_info'
52+
assert_line_text('IRB version:')
53+
type 'next'
54+
type 'info'
55+
assert_line_text([/a = 1/, /b = nil/])
56+
type 'q!'
57+
end
58+
ensure
59+
ENV["RUBY_DEBUG_IRB_CONSOLE"] = nil
60+
end
4461
end
4562
end

0 commit comments

Comments
 (0)