Skip to content

Commit

Permalink
Support activating IRB as console with a config
Browse files Browse the repository at this point in the history
  • Loading branch information
st0012 committed Dec 3, 2023
1 parent 50f1a88 commit f282982
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,7 @@ config set no_color true
* `RUBY_DEBUG_NO_RELINE` (`no_reline`): Do not use Reline library (default: false)
* `RUBY_DEBUG_NO_HINT` (`no_hint`): Do not show the hint on the REPL (default: false)
* `RUBY_DEBUG_NO_LINENO` (`no_lineno`): Do not show line numbers (default: false)
* `RUBY_DEBUG_IRB_CONSOLE` (`irb_console`): Use IRB as the console (default: false)

* CONTROL
* `RUBY_DEBUG_SKIP_PATH` (`skip_path`): Skip showing/entering frames for given paths
Expand Down
1 change: 1 addition & 0 deletions lib/debug/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ module DEBUGGER__
no_reline: ['RUBY_DEBUG_NO_RELINE', "UI: Do not use Reline library", :bool, "false"],
no_hint: ['RUBY_DEBUG_NO_HINT', "UI: Do not show the hint on the REPL", :bool, "false"],
no_lineno: ['RUBY_DEBUG_NO_LINENO', "UI: Do not show line numbers", :bool, "false"],
irb_console: ["RUBY_DEBUG_IRB_CONSOLE", "UI: Use IRB as the console", :bool, "false"],

# control setting
skip_path: ['RUBY_DEBUG_SKIP_PATH', "CONTROL: Skip showing/entering frames for given paths", :path],
Expand Down
5 changes: 5 additions & 0 deletions lib/debug/session.rb
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,11 @@ def activate ui = nil, on_fork: false
end
@tp_thread_end.enable

if CONFIG[:irb_console] && !CONFIG[:open]
require_relative "irb_integration"
thc.activate_irb_integration
end

# session start
q << true
session_server_main
Expand Down
17 changes: 17 additions & 0 deletions test/console/irb_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,22 @@ def test_irb_command_switches_console_to_irb
type 'q!'
end
end

def test_irb_console_config_activates_irb
ENV["RUBY_DEBUG_IRB_CONSOLE"] = "true"

debug_code(program, remote: false) do
type '123'
assert_line_text 'irb:rdbg(main):002> 123'
type 'irb_info'
assert_line_text('IRB version:')
type 'next'
type 'info'
assert_line_text([/a = 1/, /b = nil/])
type 'q!'
end
ensure
ENV["RUBY_DEBUG_IRB_CONSOLE"] = nil
end
end
end

0 comments on commit f282982

Please sign in to comment.