Skip to content

Commit 32e828b

Browse files
st0012matzbot
authored andcommitted
[ruby/irb] Deprecate multi-irb commands
(ruby/irb#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 ruby/irb@861731ac12
1 parent 8ecd300 commit 32e828b

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

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)