lib/irb/command/subirb.rb in irb-1.12.0 vs lib/irb/command/subirb.rb in irb-1.13.0

- old
+ new

@@ -7,13 +7,11 @@ module IRB # :stopdoc: module Command class MultiIRBCommand < Base - def execute(*args) - extend_irb_context - end + include RubyArgsExtractor private def print_deprecated_warning warn <<~MSG @@ -34,72 +32,90 @@ class IrbCommand < MultiIRBCommand category "Multi-irb (DEPRECATED)" description "Start a child IRB." - def execute(*obj) + def execute(arg) + args, kwargs = ruby_args(arg) + execute_internal(*args, **kwargs) + end + + def execute_internal(*obj) print_deprecated_warning if irb_context.with_debugger print_debugger_warning return end - super + extend_irb_context IRB.irb(nil, *obj) + puts IRB.JobManager.inspect end end class Jobs < MultiIRBCommand category "Multi-irb (DEPRECATED)" description "List of current sessions." - def execute + def execute(_arg) print_deprecated_warning if irb_context.with_debugger print_debugger_warning return end - super - IRB.JobManager + extend_irb_context + puts IRB.JobManager.inspect end end class Foreground < MultiIRBCommand category "Multi-irb (DEPRECATED)" description "Switches to the session of the given number." - def execute(key = nil) + def execute(arg) + args, kwargs = ruby_args(arg) + execute_internal(*args, **kwargs) + end + + def execute_internal(key = nil) print_deprecated_warning if irb_context.with_debugger print_debugger_warning return end - super + extend_irb_context raise CommandArgumentError.new("Please specify the id of target IRB job (listed in the `jobs` command).") unless key IRB.JobManager.switch(key) + puts IRB.JobManager.inspect end end class Kill < MultiIRBCommand category "Multi-irb (DEPRECATED)" description "Kills the session with the given number." - def execute(*keys) + def execute(arg) + args, kwargs = ruby_args(arg) + execute_internal(*args, **kwargs) + end + + def execute_internal(*keys) print_deprecated_warning if irb_context.with_debugger print_debugger_warning return end - super + extend_irb_context IRB.JobManager.kill(*keys) + puts IRB.JobManager.inspect end end end # :startdoc: