Skip to content

Commit 861731a

Browse files
authored
Deprecate multi-irb commands (#654)
* Deprecate multi-irb commands - Print deprecated message when any of the commands are used - Put related commands under `Multi-irb` category with a deprecated label * Update readme
1 parent 73b7a89 commit 861731a

File tree

2 files changed

+20
-7
lines changed

2 files changed

+20
-7
lines changed

README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# IRB
22

3-
[![Gem Version](https://badge.fury.io/rb/irb.svg)](https://badge.fury.io/rb/irb)
3+
[![Gem Version](https://badge.fury.io/rb/irb.svg)](https://badge.fury.io/rb/irb)
44
[![build](https://github.com/ruby/irb/actions/workflows/test.yml/badge.svg)](https://github.com/ruby/irb/actions/workflows/test.yml)
55

66
IRB stands for "interactive Ruby" and is a tool to interactively execute Ruby expressions read from the standard input.
@@ -96,12 +96,14 @@ IRB
9696
irb_load Load a Ruby file.
9797
irb_require Require a Ruby file.
9898
source Loads a given file in the current session.
99+
irb_info Show information about IRB.
100+
show_cmds List all available commands and their description.
101+
102+
Multi-irb (DEPRECATED)
99103
irb Start a child IRB.
100104
jobs List of current sessions.
101105
fg Switches to the session of the given number.
102106
kill Kills the session with the given number.
103-
irb_info Show information about IRB.
104-
show_cmds List all available commands and their description.
105107
106108
Debugging
107109
debug Start the debugger of debug.gem.

lib/irb/cmd/subirb.rb

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,45 +18,56 @@ def initialize(conf)
1818

1919
private
2020

21+
def print_deprecated_warning
22+
warn <<~MSG
23+
Multi-irb commands are deprecated and will be removed in IRB 2.0.0. Please use workspace commands instead.
24+
If you have any use case for multi-irb, please leave a comment at https://github.com/ruby/irb/issues/653
25+
MSG
26+
end
27+
2128
def extend_irb_context
2229
# this extension patches IRB context like IRB.CurrentContext
2330
require_relative "../ext/multi-irb"
2431
end
2532
end
2633

2734
class IrbCommand < MultiIRBCommand
28-
category "IRB"
35+
category "Multi-irb (DEPRECATED)"
2936
description "Start a child IRB."
3037

3138
def execute(*obj)
39+
print_deprecated_warning
3240
IRB.irb(nil, *obj)
3341
end
3442
end
3543

3644
class Jobs < MultiIRBCommand
37-
category "IRB"
45+
category "Multi-irb (DEPRECATED)"
3846
description "List of current sessions."
3947

4048
def execute
49+
print_deprecated_warning
4150
IRB.JobManager
4251
end
4352
end
4453

4554
class Foreground < MultiIRBCommand
46-
category "IRB"
55+
category "Multi-irb (DEPRECATED)"
4756
description "Switches to the session of the given number."
4857

4958
def execute(key = nil)
59+
print_deprecated_warning
5060
raise CommandArgumentError.new("Please specify the id of target IRB job (listed in the `jobs` command).") unless key
5161
IRB.JobManager.switch(key)
5262
end
5363
end
5464

5565
class Kill < MultiIRBCommand
56-
category "IRB"
66+
category "Multi-irb (DEPRECATED)"
5767
description "Kills the session with the given number."
5868

5969
def execute(*keys)
70+
print_deprecated_warning
6071
IRB.JobManager.kill(*keys)
6172
end
6273
end

0 commit comments

Comments
 (0)