Skip to content

Commit

Permalink
Deprecate multi-irb commands (#654)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
st0012 authored Aug 2, 2023
1 parent 73b7a89 commit 861731a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 7 deletions.
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# IRB

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

IRB stands for "interactive Ruby" and is a tool to interactively execute Ruby expressions read from the standard input.
Expand Down Expand Up @@ -96,12 +96,14 @@ IRB
irb_load Load a Ruby file.
irb_require Require a Ruby file.
source Loads a given file in the current session.
irb_info Show information about IRB.
show_cmds List all available commands and their description.
Multi-irb (DEPRECATED)
irb Start a child IRB.
jobs List of current sessions.
fg Switches to the session of the given number.
kill Kills the session with the given number.
irb_info Show information about IRB.
show_cmds List all available commands and their description.
Debugging
debug Start the debugger of debug.gem.
Expand Down
19 changes: 15 additions & 4 deletions lib/irb/cmd/subirb.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,45 +18,56 @@ def initialize(conf)

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
end

class IrbCommand < MultiIRBCommand
category "IRB"
category "Multi-irb (DEPRECATED)"
description "Start a child IRB."

def execute(*obj)
print_deprecated_warning
IRB.irb(nil, *obj)
end
end

class Jobs < MultiIRBCommand
category "IRB"
category "Multi-irb (DEPRECATED)"
description "List of current sessions."

def execute
print_deprecated_warning
IRB.JobManager
end
end

class Foreground < MultiIRBCommand
category "IRB"
category "Multi-irb (DEPRECATED)"
description "Switches to the session of the given number."

def execute(key = nil)
print_deprecated_warning
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 "IRB"
category "Multi-irb (DEPRECATED)"
description "Kills the session with the given number."

def execute(*keys)
print_deprecated_warning
IRB.JobManager.kill(*keys)
end
end
Expand Down

0 comments on commit 861731a

Please sign in to comment.