blob: 5ffd646416707f6532cf892791927f37441a5c2d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
|
# frozen_string_literal: false
#
# multi.rb -
# by Keiju ISHITSUKA([email protected])
#
require_relative "nop"
module IRB
# :stopdoc:
module ExtendCommand
class MultiIRBCommand < Nop
def execute(*args)
extend_irb_context
end
private
def print_deprecated_warning
warn <<~MSG
Multi-irb commands are deprecated and will be removed in IRB 2.0.0. Please use workspace commands instead.
If you have any use case for multi-irb, please leave a comment at https://github.com/ruby/irb/issues/653
MSG
end
def extend_irb_context
# this extension patches IRB context like IRB.CurrentContext
require_relative "../ext/multi-irb"
end
def print_debugger_warning
warn "Multi-IRB commands are not available when the debugger is enabled."
end
end
class IrbCommand < MultiIRBCommand
category "Multi-irb (DEPRECATED)"
description "Start a child IRB."
def execute(*obj)
print_deprecated_warning
if irb_context.with_debugger
print_debugger_warning
return
end
super
IRB.irb(nil, *obj)
end
end
class Jobs < MultiIRBCommand
category "Multi-irb (DEPRECATED)"
description "List of current sessions."
def execute
print_deprecated_warning
if irb_context.with_debugger
print_debugger_warning
return
end
super
IRB.JobManager
end
end
class Foreground < MultiIRBCommand
category "Multi-irb (DEPRECATED)"
description "Switches to the session of the given number."
def execute(key = nil)
print_deprecated_warning
if irb_context.with_debugger
print_debugger_warning
return
end
super
raise CommandArgumentError.new("Please specify the id of target IRB job (listed in the `jobs` command).") unless key
IRB.JobManager.switch(key)
end
end
class Kill < MultiIRBCommand
category "Multi-irb (DEPRECATED)"
description "Kills the session with the given number."
def execute(*keys)
print_deprecated_warning
if irb_context.with_debugger
print_debugger_warning
return
end
super
IRB.JobManager.kill(*keys)
end
end
end
# :startdoc:
end
|