summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStan Lo <[email protected]>2024-02-16 16:47:32 +0000
committergit <[email protected]>2024-02-16 16:47:36 +0000
commitf5801e2bf404cbb0f673a6ebb040b0ba6cd01b77 (patch)
tree8ee0d5041c9d46df4448c80c28ffb929daabe4b4
parent4411cdeef9f49cc295b2456b15a14550e8d88804 (diff)
[ruby/irb] Standardize command related names
(https://github.com/ruby/irb/pull/873) * Replace ExtendCommand with Command and standardize command related names 1. Rename lib/irb/extend-command.rb to lib/irb/command.rb 2. Rename lib/irb/cmd/*.rb to lib/irb/command/*.rb 3. Rename test/irb/test_cmd.rb to test/irb/test_command.rb 4. Rename ExtendCommand to Command * Alias ExtendCommand to Command and deprecate it * Rename Command::Nop to Command::Base * Not deprecate old constants just yet * Add lib/irb/cmd/nop.rb back https://github.com/ruby/irb/commit/462c1284af
-rw-r--r--lib/irb.rb2
-rw-r--r--lib/irb/cmd/nop.rb55
-rw-r--r--lib/irb/command.rb (renamed from lib/irb/extend-command.rb)85
-rw-r--r--lib/irb/command/backtrace.rb (renamed from lib/irb/cmd/backtrace.rb)2
-rw-r--r--lib/irb/command/base.rb55
-rw-r--r--lib/irb/command/break.rb (renamed from lib/irb/cmd/break.rb)2
-rw-r--r--lib/irb/command/catch.rb (renamed from lib/irb/cmd/catch.rb)2
-rw-r--r--lib/irb/command/chws.rb (renamed from lib/irb/cmd/chws.rb)8
-rw-r--r--lib/irb/command/continue.rb (renamed from lib/irb/cmd/continue.rb)2
-rw-r--r--lib/irb/command/debug.rb (renamed from lib/irb/cmd/debug.rb)5
-rw-r--r--lib/irb/command/delete.rb (renamed from lib/irb/cmd/delete.rb)2
-rw-r--r--lib/irb/command/edit.rb (renamed from lib/irb/cmd/edit.rb)6
-rw-r--r--lib/irb/command/exit.rb (renamed from lib/irb/cmd/exit.rb)6
-rw-r--r--lib/irb/command/finish.rb (renamed from lib/irb/cmd/finish.rb)2
-rw-r--r--lib/irb/command/force_exit.rb (renamed from lib/irb/cmd/force_exit.rb)6
-rw-r--r--lib/irb/command/help.rb (renamed from lib/irb/cmd/help.rb)2
-rw-r--r--lib/irb/command/history.rb (renamed from lib/irb/cmd/history.rb)6
-rw-r--r--lib/irb/command/info.rb (renamed from lib/irb/cmd/info.rb)2
-rw-r--r--lib/irb/command/irb_info.rb (renamed from lib/irb/cmd/irb_info.rb)6
-rw-r--r--lib/irb/command/load.rb (renamed from lib/irb/cmd/load.rb)6
-rw-r--r--lib/irb/command/ls.rb (renamed from lib/irb/cmd/ls.rb)6
-rw-r--r--lib/irb/command/measure.rb (renamed from lib/irb/cmd/measure.rb)6
-rw-r--r--lib/irb/command/next.rb (renamed from lib/irb/cmd/next.rb)2
-rw-r--r--lib/irb/command/pushws.rb (renamed from lib/irb/cmd/pushws.rb)5
-rw-r--r--lib/irb/command/show_cmds.rb (renamed from lib/irb/cmd/show_cmds.rb)6
-rw-r--r--lib/irb/command/show_doc.rb (renamed from lib/irb/cmd/show_doc.rb)6
-rw-r--r--lib/irb/command/show_source.rb (renamed from lib/irb/cmd/show_source.rb)5
-rw-r--r--lib/irb/command/step.rb (renamed from lib/irb/cmd/step.rb)2
-rw-r--r--lib/irb/command/subirb.rb (renamed from lib/irb/cmd/subirb.rb)6
-rw-r--r--lib/irb/command/whereami.rb (renamed from lib/irb/cmd/whereami.rb)6
-rw-r--r--lib/irb/ext/use-loader.rb4
-rw-r--r--lib/irb/statement.rb6
-rw-r--r--test/irb/test_command.rb (renamed from test/irb/test_cmd.rb)5
33 files changed, 158 insertions, 169 deletions
diff --git a/lib/irb.rb b/lib/irb.rb
index fd06626e9b..73d96947ea 100644
--- a/lib/irb.rb
+++ b/lib/irb.rb
@@ -9,7 +9,7 @@ require "reline"
require_relative "irb/init"
require_relative "irb/context"
-require_relative "irb/extend-command"
+require_relative "irb/command"
require_relative "irb/ruby-lex"
require_relative "irb/statement"
diff --git a/lib/irb/cmd/nop.rb b/lib/irb/cmd/nop.rb
index 7fb197c51f..49f89bac95 100644
--- a/lib/irb/cmd/nop.rb
+++ b/lib/irb/cmd/nop.rb
@@ -1,53 +1,4 @@
-# frozen_string_literal: false
-#
-# nop.rb -
-# by Keiju ISHITSUKA([email protected])
-#
+# frozen_string_literal: true
-module IRB
- # :stopdoc:
-
- module ExtendCommand
- class CommandArgumentError < StandardError; end
-
- class Nop
- class << self
- def category(category = nil)
- @category = category if category
- @category
- end
-
- def description(description = nil)
- @description = description if description
- @description
- end
-
- private
-
- def string_literal?(args)
- sexp = Ripper.sexp(args)
- sexp && sexp.size == 2 && sexp.last&.first&.first == :string_literal
- end
- end
-
- def self.execute(irb_context, *opts, **kwargs, &block)
- command = new(irb_context)
- command.execute(*opts, **kwargs, &block)
- rescue CommandArgumentError => e
- puts e.message
- end
-
- def initialize(irb_context)
- @irb_context = irb_context
- end
-
- attr_reader :irb_context
-
- def execute(*opts)
- #nop
- end
- end
- end
-
- # :startdoc:
-end
+# This file is just a placeholder for backward-compatibility.
+# Please require 'irb' and inheirt your command from `IRB::Command::Base` instead.
diff --git a/lib/irb/extend-command.rb b/lib/irb/command.rb
index d303bf76da..cab571cfe3 100644
--- a/lib/irb/extend-command.rb
+++ b/lib/irb/command.rb
@@ -1,10 +1,15 @@
# frozen_string_literal: false
#
-# irb/extend-command.rb - irb extend command
+# irb/command.rb - irb command
# by Keiju ISHITSUKA([email protected])
#
+require_relative "command/base"
+
module IRB # :nodoc:
+ module Command; end
+ ExtendCommand = Command
+
# Installs the default irb extensions command bundle.
module ExtendCommandBundle
EXCB = ExtendCommandBundle # :nodoc:
@@ -31,18 +36,18 @@ module IRB # :nodoc:
@EXTEND_COMMANDS = [
[
- :irb_exit, :Exit, "cmd/exit",
+ :irb_exit, :Exit, "command/exit",
[:exit, OVERRIDE_PRIVATE_ONLY],
[:quit, OVERRIDE_PRIVATE_ONLY],
[:irb_quit, OVERRIDE_PRIVATE_ONLY],
],
[
- :irb_exit!, :ForceExit, "cmd/force_exit",
+ :irb_exit!, :ForceExit, "command/force_exit",
[:exit!, OVERRIDE_PRIVATE_ONLY],
],
[
- :irb_current_working_workspace, :CurrentWorkingWorkspace, "cmd/chws",
+ :irb_current_working_workspace, :CurrentWorkingWorkspace, "command/chws",
[:cwws, NO_OVERRIDE],
[:pwws, NO_OVERRIDE],
[:irb_print_working_workspace, OVERRIDE_ALL],
@@ -54,7 +59,7 @@ module IRB # :nodoc:
[:irb_pwb, OVERRIDE_ALL],
],
[
- :irb_change_workspace, :ChangeWorkspace, "cmd/chws",
+ :irb_change_workspace, :ChangeWorkspace, "command/chws",
[:chws, NO_OVERRIDE],
[:cws, NO_OVERRIDE],
[:irb_chws, OVERRIDE_ALL],
@@ -65,13 +70,13 @@ module IRB # :nodoc:
],
[
- :irb_workspaces, :Workspaces, "cmd/pushws",
+ :irb_workspaces, :Workspaces, "command/pushws",
[:workspaces, NO_OVERRIDE],
[:irb_bindings, OVERRIDE_ALL],
[:bindings, NO_OVERRIDE],
],
[
- :irb_push_workspace, :PushWorkspace, "cmd/pushws",
+ :irb_push_workspace, :PushWorkspace, "command/pushws",
[:pushws, NO_OVERRIDE],
[:irb_pushws, OVERRIDE_ALL],
[:irb_push_binding, OVERRIDE_ALL],
@@ -79,7 +84,7 @@ module IRB # :nodoc:
[:pushb, NO_OVERRIDE],
],
[
- :irb_pop_workspace, :PopWorkspace, "cmd/pushws",
+ :irb_pop_workspace, :PopWorkspace, "command/pushws",
[:popws, NO_OVERRIDE],
[:irb_popws, OVERRIDE_ALL],
[:irb_pop_binding, OVERRIDE_ALL],
@@ -88,112 +93,112 @@ module IRB # :nodoc:
],
[
- :irb_load, :Load, "cmd/load"],
+ :irb_load, :Load, "command/load"],
[
- :irb_require, :Require, "cmd/load"],
+ :irb_require, :Require, "command/load"],
[
- :irb_source, :Source, "cmd/load",
+ :irb_source, :Source, "command/load",
[:source, NO_OVERRIDE],
],
[
- :irb, :IrbCommand, "cmd/subirb"],
+ :irb, :IrbCommand, "command/subirb"],
[
- :irb_jobs, :Jobs, "cmd/subirb",
+ :irb_jobs, :Jobs, "command/subirb",
[:jobs, NO_OVERRIDE],
],
[
- :irb_fg, :Foreground, "cmd/subirb",
+ :irb_fg, :Foreground, "command/subirb",
[:fg, NO_OVERRIDE],
],
[
- :irb_kill, :Kill, "cmd/subirb",
+ :irb_kill, :Kill, "command/subirb",
[:kill, OVERRIDE_PRIVATE_ONLY],
],
[
- :irb_debug, :Debug, "cmd/debug",
+ :irb_debug, :Debug, "command/debug",
[:debug, NO_OVERRIDE],
],
[
- :irb_edit, :Edit, "cmd/edit",
+ :irb_edit, :Edit, "command/edit",
[:edit, NO_OVERRIDE],
],
[
- :irb_break, :Break, "cmd/break",
+ :irb_break, :Break, "command/break",
],
[
- :irb_catch, :Catch, "cmd/catch",
+ :irb_catch, :Catch, "command/catch",
],
[
- :irb_next, :Next, "cmd/next"
+ :irb_next, :Next, "command/next"
],
[
- :irb_delete, :Delete, "cmd/delete",
+ :irb_delete, :Delete, "command/delete",
[:delete, NO_OVERRIDE],
],
[
- :irb_step, :Step, "cmd/step",
+ :irb_step, :Step, "command/step",
[:step, NO_OVERRIDE],
],
[
- :irb_continue, :Continue, "cmd/continue",
+ :irb_continue, :Continue, "command/continue",
[:continue, NO_OVERRIDE],
],
[
- :irb_finish, :Finish, "cmd/finish",
+ :irb_finish, :Finish, "command/finish",
[:finish, NO_OVERRIDE],
],
[
- :irb_backtrace, :Backtrace, "cmd/backtrace",
+ :irb_backtrace, :Backtrace, "command/backtrace",
[:backtrace, NO_OVERRIDE],
[:bt, NO_OVERRIDE],
],
[
- :irb_debug_info, :Info, "cmd/info",
+ :irb_debug_info, :Info, "command/info",
[:info, NO_OVERRIDE],
],
[
- :irb_help, :Help, "cmd/help",
+ :irb_help, :Help, "command/help",
[:help, NO_OVERRIDE],
],
[
- :irb_show_doc, :ShowDoc, "cmd/show_doc",
+ :irb_show_doc, :ShowDoc, "command/show_doc",
[:show_doc, NO_OVERRIDE],
],
[
- :irb_info, :IrbInfo, "cmd/irb_info"
+ :irb_info, :IrbInfo, "command/irb_info"
],
[
- :irb_ls, :Ls, "cmd/ls",
+ :irb_ls, :Ls, "command/ls",
[:ls, NO_OVERRIDE],
],
[
- :irb_measure, :Measure, "cmd/measure",
+ :irb_measure, :Measure, "command/measure",
[:measure, NO_OVERRIDE],
],
[
- :irb_show_source, :ShowSource, "cmd/show_source",
+ :irb_show_source, :ShowSource, "command/show_source",
[:show_source, NO_OVERRIDE],
],
[
- :irb_whereami, :Whereami, "cmd/whereami",
+ :irb_whereami, :Whereami, "command/whereami",
[:whereami, NO_OVERRIDE],
],
[
- :irb_show_cmds, :ShowCmds, "cmd/show_cmds",
+ :irb_show_cmds, :ShowCmds, "command/show_cmds",
[:show_cmds, NO_OVERRIDE],
],
[
- :irb_history, :History, "cmd/history",
+ :irb_history, :History, "command/history",
[:history, NO_OVERRIDE],
[:hist, NO_OVERRIDE],
]
@@ -210,11 +215,11 @@ module IRB # :nodoc:
end
@EXTEND_COMMANDS.each do |cmd_name, cmd_class, load_file, *aliases|
- if !defined?(ExtendCommand) || !ExtendCommand.const_defined?(cmd_class, false)
+ if !defined?(Command) || !Command.const_defined?(cmd_class, false)
require_relative load_file
end
- klass = ExtendCommand.const_get(cmd_class, false)
+ klass = Command.const_get(cmd_class, false)
aliases = aliases.map { |a| a.first }
if additional_aliases = user_aliases[cmd_name]
@@ -234,10 +239,10 @@ module IRB # :nodoc:
@EXTEND_COMMANDS.each do |cmd_name, cmd_class, load_file, *aliases|
next if cmd_name != command && aliases.all? { |alias_name, _| alias_name != command }
- if !defined?(ExtendCommand) || !ExtendCommand.const_defined?(cmd_class, false)
+ if !defined?(Command) || !Command.const_defined?(cmd_class, false)
require_relative load_file
end
- return ExtendCommand.const_get(cmd_class, false)
+ return Command.const_get(cmd_class, false)
end
nil
end
@@ -267,7 +272,7 @@ module IRB # :nodoc:
line = __LINE__; eval %[
def #{cmd_name}(*opts, **kwargs, &b)
Kernel.require_relative "#{load_file}"
- ::IRB::ExtendCommand::#{cmd_class}.execute(irb_context, *opts, **kwargs, &b)
+ ::IRB::Command::#{cmd_class}.execute(irb_context, *opts, **kwargs, &b)
end
], nil, __FILE__, line
diff --git a/lib/irb/cmd/backtrace.rb b/lib/irb/command/backtrace.rb
index f632894618..47e5e60724 100644
--- a/lib/irb/cmd/backtrace.rb
+++ b/lib/irb/command/backtrace.rb
@@ -5,7 +5,7 @@ require_relative "debug"
module IRB
# :stopdoc:
- module ExtendCommand
+ module Command
class Backtrace < DebugCommand
def self.transform_args(args)
args&.dump
diff --git a/lib/irb/command/base.rb b/lib/irb/command/base.rb
new file mode 100644
index 0000000000..87d2fea356
--- /dev/null
+++ b/lib/irb/command/base.rb
@@ -0,0 +1,55 @@
+# frozen_string_literal: false
+#
+# nop.rb -
+# by Keiju ISHITSUKA([email protected])
+#
+
+module IRB
+ # :stopdoc:
+
+ module Command
+ class CommandArgumentError < StandardError; end
+
+ class Base
+ class << self
+ def category(category = nil)
+ @category = category if category
+ @category
+ end
+
+ def description(description = nil)
+ @description = description if description
+ @description
+ end
+
+ private
+
+ def string_literal?(args)
+ sexp = Ripper.sexp(args)
+ sexp && sexp.size == 2 && sexp.last&.first&.first == :string_literal
+ end
+ end
+
+ def self.execute(irb_context, *opts, **kwargs, &block)
+ command = new(irb_context)
+ command.execute(*opts, **kwargs, &block)
+ rescue CommandArgumentError => e
+ puts e.message
+ end
+
+ def initialize(irb_context)
+ @irb_context = irb_context
+ end
+
+ attr_reader :irb_context
+
+ def execute(*opts)
+ #nop
+ end
+ end
+
+ Nop = Base
+ end
+
+ # :startdoc:
+end
diff --git a/lib/irb/cmd/break.rb b/lib/irb/command/break.rb
index df259a90ca..fa200f2d78 100644
--- a/lib/irb/cmd/break.rb
+++ b/lib/irb/command/break.rb
@@ -5,7 +5,7 @@ require_relative "debug"
module IRB
# :stopdoc:
- module ExtendCommand
+ module Command
class Break < DebugCommand
def self.transform_args(args)
args&.dump
diff --git a/lib/irb/cmd/catch.rb b/lib/irb/command/catch.rb
index 40b62c7533..6b2edff5e5 100644
--- a/lib/irb/cmd/catch.rb
+++ b/lib/irb/command/catch.rb
@@ -5,7 +5,7 @@ require_relative "debug"
module IRB
# :stopdoc:
- module ExtendCommand
+ module Command
class Catch < DebugCommand
def self.transform_args(args)
args&.dump
diff --git a/lib/irb/cmd/chws.rb b/lib/irb/command/chws.rb
index 31045f9bbb..341d516155 100644
--- a/lib/irb/cmd/chws.rb
+++ b/lib/irb/command/chws.rb
@@ -3,16 +3,14 @@
# change-ws.rb -
# by Keiju ISHITSUKA([email protected])
#
-
-require_relative "nop"
require_relative "../ext/change-ws"
module IRB
# :stopdoc:
- module ExtendCommand
+ module Command
- class CurrentWorkingWorkspace < Nop
+ class CurrentWorkingWorkspace < Base
category "Workspace"
description "Show the current workspace."
@@ -21,7 +19,7 @@ module IRB
end
end
- class ChangeWorkspace < Nop
+ class ChangeWorkspace < Base
category "Workspace"
description "Change the current workspace to an object."
diff --git a/lib/irb/cmd/continue.rb b/lib/irb/command/continue.rb
index 9136177eef..8b6ffc860c 100644
--- a/lib/irb/cmd/continue.rb
+++ b/lib/irb/command/continue.rb
@@ -5,7 +5,7 @@ require_relative "debug"
module IRB
# :stopdoc:
- module ExtendCommand
+ module Command
class Continue < DebugCommand
def execute(*args)
super(do_cmds: ["continue", *args].join(" "))
diff --git a/lib/irb/cmd/debug.rb b/lib/irb/command/debug.rb
index e236084ca4..9a2c641251 100644
--- a/lib/irb/cmd/debug.rb
+++ b/lib/irb/command/debug.rb
@@ -1,11 +1,10 @@
-require_relative "nop"
require_relative "../debug"
module IRB
# :stopdoc:
- module ExtendCommand
- class Debug < Nop
+ module Command
+ class Debug < Base
category "Debugging"
description "Start the debugger of debug.gem."
diff --git a/lib/irb/cmd/delete.rb b/lib/irb/command/delete.rb
index aeb26d2572..a36b4577b0 100644
--- a/lib/irb/cmd/delete.rb
+++ b/lib/irb/command/delete.rb
@@ -5,7 +5,7 @@ require_relative "debug"
module IRB
# :stopdoc:
- module ExtendCommand
+ module Command
class Delete < DebugCommand
def execute(*args)
super(pre_cmds: ["delete", *args].join(" "))
diff --git a/lib/irb/cmd/edit.rb b/lib/irb/command/edit.rb
index dae65f3c39..1a8ded6bcf 100644
--- a/lib/irb/cmd/edit.rb
+++ b/lib/irb/command/edit.rb
@@ -1,12 +1,12 @@
require 'shellwords'
-require_relative "nop"
+
require_relative "../source_finder"
module IRB
# :stopdoc:
- module ExtendCommand
- class Edit < Nop
+ module Command
+ class Edit < Base
category "Misc"
description 'Open a file with the editor command defined with `ENV["VISUAL"]` or `ENV["EDITOR"]`.'
diff --git a/lib/irb/cmd/exit.rb b/lib/irb/command/exit.rb
index 415e555335..3109ec16e3 100644
--- a/lib/irb/cmd/exit.rb
+++ b/lib/irb/command/exit.rb
@@ -1,12 +1,10 @@
# frozen_string_literal: true
-require_relative "nop"
-
module IRB
# :stopdoc:
- module ExtendCommand
- class Exit < Nop
+ module Command
+ class Exit < Base
category "IRB"
description "Exit the current irb session."
diff --git a/lib/irb/cmd/finish.rb b/lib/irb/command/finish.rb
index 29f100feb5..05501819e2 100644
--- a/lib/irb/cmd/finish.rb
+++ b/lib/irb/command/finish.rb
@@ -5,7 +5,7 @@ require_relative "debug"
module IRB
# :stopdoc:
- module ExtendCommand
+ module Command
class Finish < DebugCommand
def execute(*args)
super(do_cmds: ["finish", *args].join(" "))
diff --git a/lib/irb/cmd/force_exit.rb b/lib/irb/command/force_exit.rb
index 7e9b308de0..c2c5542e24 100644
--- a/lib/irb/cmd/force_exit.rb
+++ b/lib/irb/command/force_exit.rb
@@ -1,12 +1,10 @@
# frozen_string_literal: true
-require_relative "nop"
-
module IRB
# :stopdoc:
- module ExtendCommand
- class ForceExit < Nop
+ module Command
+ class ForceExit < Base
category "IRB"
description "Exit the current process."
diff --git a/lib/irb/cmd/help.rb b/lib/irb/command/help.rb
index 7f894688cc..67cc31a0bf 100644
--- a/lib/irb/cmd/help.rb
+++ b/lib/irb/command/help.rb
@@ -3,7 +3,7 @@
require_relative "show_cmds"
module IRB
- module ExtendCommand
+ module Command
class Help < ShowCmds
category "IRB"
description "List all available commands and their description."
diff --git a/lib/irb/cmd/history.rb b/lib/irb/command/history.rb
index 5b712fa44d..a47a8795dd 100644
--- a/lib/irb/cmd/history.rb
+++ b/lib/irb/command/history.rb
@@ -1,14 +1,14 @@
# frozen_string_literal: true
require "stringio"
-require_relative "nop"
+
require_relative "../pager"
module IRB
# :stopdoc:
- module ExtendCommand
- class History < Nop
+ module Command
+ class History < Base
category "IRB"
description "Shows the input history. `-g [query]` or `-G [query]` allows you to filter the output."
diff --git a/lib/irb/cmd/info.rb b/lib/irb/command/info.rb
index 2c0a32b34f..a67be3eb85 100644
--- a/lib/irb/cmd/info.rb
+++ b/lib/irb/command/info.rb
@@ -5,7 +5,7 @@ require_relative "debug"
module IRB
# :stopdoc:
- module ExtendCommand
+ module Command
class Info < DebugCommand
def self.transform_args(args)
args&.dump
diff --git a/lib/irb/cmd/irb_info.rb b/lib/irb/command/irb_info.rb
index 5b905a09bd..7fd3e2104a 100644
--- a/lib/irb/cmd/irb_info.rb
+++ b/lib/irb/command/irb_info.rb
@@ -1,12 +1,10 @@
# frozen_string_literal: false
-require_relative "nop"
-
module IRB
# :stopdoc:
- module ExtendCommand
- class IrbInfo < Nop
+ module Command
+ class IrbInfo < Base
category "IRB"
description "Show information about IRB."
diff --git a/lib/irb/cmd/load.rb b/lib/irb/command/load.rb
index a3e797a7e0..0558bc83b0 100644
--- a/lib/irb/cmd/load.rb
+++ b/lib/irb/command/load.rb
@@ -3,15 +3,13 @@
# load.rb -
# by Keiju ISHITSUKA([email protected])
#
-
-require_relative "nop"
require_relative "../ext/loader"
module IRB
# :stopdoc:
- module ExtendCommand
- class LoaderCommand < Nop
+ module Command
+ class LoaderCommand < Base
include IrbLoader
def raise_cmd_argument_error
diff --git a/lib/irb/cmd/ls.rb b/lib/irb/command/ls.rb
index 791b1c1b21..bbe4a1ee98 100644
--- a/lib/irb/cmd/ls.rb
+++ b/lib/irb/command/ls.rb
@@ -2,15 +2,15 @@
require "reline"
require "stringio"
-require_relative "nop"
+
require_relative "../pager"
require_relative "../color"
module IRB
# :stopdoc:
- module ExtendCommand
- class Ls < Nop
+ module Command
+ class Ls < Base
category "Context"
description "Show methods, constants, and variables. `-g [query]` or `-G [query]` allows you to filter out the output."
diff --git a/lib/irb/cmd/measure.rb b/lib/irb/command/measure.rb
index 4e1125a0a6..ee7927b010 100644
--- a/lib/irb/cmd/measure.rb
+++ b/lib/irb/command/measure.rb
@@ -1,10 +1,8 @@
-require_relative "nop"
-
module IRB
# :stopdoc:
- module ExtendCommand
- class Measure < Nop
+ module Command
+ class Measure < Base
category "Misc"
description "`measure` enables the mode to measure processing time. `measure :off` disables it."
diff --git a/lib/irb/cmd/next.rb b/lib/irb/command/next.rb
index d29c82e7fc..6487c9d24c 100644
--- a/lib/irb/cmd/next.rb
+++ b/lib/irb/command/next.rb
@@ -5,7 +5,7 @@ require_relative "debug"
module IRB
# :stopdoc:
- module ExtendCommand
+ module Command
class Next < DebugCommand
def execute(*args)
super(do_cmds: ["next", *args].join(" "))
diff --git a/lib/irb/cmd/pushws.rb b/lib/irb/command/pushws.rb
index 59996ceb0c..a6fcd6a165 100644
--- a/lib/irb/cmd/pushws.rb
+++ b/lib/irb/command/pushws.rb
@@ -4,14 +4,13 @@
# by Keiju ISHITSUKA([email protected])
#
-require_relative "nop"
require_relative "../ext/workspaces"
module IRB
# :stopdoc:
- module ExtendCommand
- class Workspaces < Nop
+ module Command
+ class Workspaces < Base
category "Workspace"
description "Show workspaces."
diff --git a/lib/irb/cmd/show_cmds.rb b/lib/irb/command/show_cmds.rb
index a8d899e4ac..940ed490d3 100644
--- a/lib/irb/cmd/show_cmds.rb
+++ b/lib/irb/command/show_cmds.rb
@@ -1,14 +1,14 @@
# frozen_string_literal: true
require "stringio"
-require_relative "nop"
+
require_relative "../pager"
module IRB
# :stopdoc:
- module ExtendCommand
- class ShowCmds < Nop
+ module Command
+ class ShowCmds < Base
category "IRB"
description "List all available commands and their description."
diff --git a/lib/irb/cmd/show_doc.rb b/lib/irb/command/show_doc.rb
index 99dd9ab95a..dca10ec4be 100644
--- a/lib/irb/cmd/show_doc.rb
+++ b/lib/irb/command/show_doc.rb
@@ -1,10 +1,8 @@
# frozen_string_literal: true
-require_relative "nop"
-
module IRB
- module ExtendCommand
- class ShowDoc < Nop
+ module Command
+ class ShowDoc < Base
class << self
def transform_args(args)
# Return a string literal as is for backward compatibility
diff --git a/lib/irb/cmd/show_source.rb b/lib/irb/command/show_source.rb
index cd07de3e90..cc783e7532 100644
--- a/lib/irb/cmd/show_source.rb
+++ b/lib/irb/command/show_source.rb
@@ -1,13 +1,12 @@
# frozen_string_literal: true
-require_relative "nop"
require_relative "../source_finder"
require_relative "../pager"
require_relative "../color"
module IRB
- module ExtendCommand
- class ShowSource < Nop
+ module Command
+ class ShowSource < Base
category "Context"
description "Show the source code of a given method or constant."
diff --git a/lib/irb/cmd/step.rb b/lib/irb/command/step.rb
index 2bc74a9d79..cce7d2b0f8 100644
--- a/lib/irb/cmd/step.rb
+++ b/lib/irb/command/step.rb
@@ -5,7 +5,7 @@ require_relative "debug"
module IRB
# :stopdoc:
- module ExtendCommand
+ module Command
class Step < DebugCommand
def execute(*args)
super(do_cmds: ["step", *args].join(" "))
diff --git a/lib/irb/cmd/subirb.rb b/lib/irb/command/subirb.rb
index 5ffd646416..0a75706f5f 100644
--- a/lib/irb/cmd/subirb.rb
+++ b/lib/irb/command/subirb.rb
@@ -4,13 +4,11 @@
# by Keiju ISHITSUKA([email protected])
#
-require_relative "nop"
-
module IRB
# :stopdoc:
- module ExtendCommand
- class MultiIRBCommand < Nop
+ module Command
+ class MultiIRBCommand < Base
def execute(*args)
extend_irb_context
end
diff --git a/lib/irb/cmd/whereami.rb b/lib/irb/command/whereami.rb
index 8f56ba073d..d6658d7043 100644
--- a/lib/irb/cmd/whereami.rb
+++ b/lib/irb/command/whereami.rb
@@ -1,12 +1,10 @@
# frozen_string_literal: true
-require_relative "nop"
-
module IRB
# :stopdoc:
- module ExtendCommand
- class Whereami < Nop
+ module Command
+ class Whereami < Base
category "Context"
description "Show the source code around binding.irb again."
diff --git a/lib/irb/ext/use-loader.rb b/lib/irb/ext/use-loader.rb
index d0b8c2d4f4..c5ecbe2847 100644
--- a/lib/irb/ext/use-loader.rb
+++ b/lib/irb/ext/use-loader.rb
@@ -17,12 +17,12 @@ module IRB
remove_method :irb_load if method_defined?(:irb_load)
# Loads the given file similarly to Kernel#load, see IrbLoader#irb_load
def irb_load(*opts, &b)
- ExtendCommand::Load.execute(irb_context, *opts, &b)
+ Command::Load.execute(irb_context, *opts, &b)
end
remove_method :irb_require if method_defined?(:irb_require)
# Loads the given file similarly to Kernel#require
def irb_require(*opts, &b)
- ExtendCommand::Require.execute(irb_context, *opts, &b)
+ Command::Require.execute(irb_context, *opts, &b)
end
end
diff --git a/lib/irb/statement.rb b/lib/irb/statement.rb
index 4e17e51434..009eb2d20b 100644
--- a/lib/irb/statement.rb
+++ b/lib/irb/statement.rb
@@ -83,9 +83,9 @@ module IRB
end
def should_be_handled_by_debugger?
- require_relative 'cmd/help'
- require_relative 'cmd/debug'
- IRB::ExtendCommand::DebugCommand > @command_class || IRB::ExtendCommand::Help == @command_class
+ require_relative 'command/help'
+ require_relative 'command/debug'
+ IRB::Command::DebugCommand > @command_class || IRB::Command::Help == @command_class
end
def evaluable_code
diff --git a/test/irb/test_cmd.rb b/test/irb/test_command.rb
index b9a155ec09..15ae6a658e 100644
--- a/test/irb/test_cmd.rb
+++ b/test/irb/test_command.rb
@@ -1,7 +1,6 @@
# frozen_string_literal: false
require "rubygems"
require "irb"
-require "irb/extend-command"
require_relative "helper"
@@ -797,7 +796,7 @@ module TestIRB
assert(possible_rdoc_output.any? { |output| output.match?(out) }, "Expect the `show_doc` command to match one of the possible outputs. Got:\n#{out}")
ensure
# this is the only way to reset the redefined method without coupling the test with its implementation
- EnvUtil.suppress_warning { load "irb/cmd/help.rb" }
+ EnvUtil.suppress_warning { load "irb/command/help.rb" }
end
def test_show_doc_without_rdoc
@@ -813,7 +812,7 @@ module TestIRB
assert_include(err, "Can't display document because `rdoc` is not installed.\n")
ensure
# this is the only way to reset the redefined method without coupling the test with its implementation
- EnvUtil.suppress_warning { load "irb/cmd/help.rb" }
+ EnvUtil.suppress_warning { load "irb/command/help.rb" }
end
end