Skip to content

Commit d9192d9

Browse files
authored
Repurpose the help command to display the help message (#872)
See #787 for more details.
1 parent 87c279c commit d9192d9

File tree

2 files changed

+14
-31
lines changed

2 files changed

+14
-31
lines changed

lib/irb/cmd/help.rb

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,12 @@
11
# frozen_string_literal: true
22

3-
require_relative "show_doc"
3+
require_relative "show_cmds"
44

55
module IRB
66
module ExtendCommand
7-
class Help < ShowDoc
8-
category "Context"
9-
description "[DEPRECATED] Enter the mode to look up RI documents."
10-
11-
DEPRECATION_MESSAGE = <<~MSG
12-
[Deprecation] The `help` command will be repurposed to display command help in the future.
13-
For RI document lookup, please use the `show_doc` command instead.
14-
For command help, please use `show_cmds` for now.
15-
MSG
16-
17-
def execute(*names)
18-
warn DEPRECATION_MESSAGE
19-
super
20-
end
7+
class Help < ShowCmds
8+
category "IRB"
9+
description "List all available commands and their description."
2110
end
2211
end
2312
end

test/irb/test_cmd.rb

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -603,6 +603,16 @@ def test_whereami_alias
603603

604604

605605
class ShowCmdsTest < CommandTestCase
606+
def test_help
607+
out, err = execute_lines(
608+
"help\n",
609+
)
610+
611+
assert_empty err
612+
assert_match(/List all available commands and their description/, out)
613+
assert_match(/Start the debugger of debug\.gem/, out)
614+
end
615+
606616
def test_show_cmds
607617
out, err = execute_lines(
608618
"show_cmds\n"
@@ -774,22 +784,6 @@ def test_ls_with_no_singleton_class
774784
end
775785

776786
class ShowDocTest < CommandTestCase
777-
def test_help
778-
out, err = execute_lines(
779-
"help String#gsub\n",
780-
"\n",
781-
)
782-
783-
# the former is what we'd get without document content installed, like on CI
784-
# the latter is what we may get locally
785-
possible_rdoc_output = [/Nothing known about String#gsub/, /gsub\(pattern\)/]
786-
assert_include err, "[Deprecation] The `help` command will be repurposed to display command help in the future.\n"
787-
assert(possible_rdoc_output.any? { |output| output.match?(out) }, "Expect the `help` command to match one of the possible outputs. Got:\n#{out}")
788-
ensure
789-
# this is the only way to reset the redefined method without coupling the test with its implementation
790-
EnvUtil.suppress_warning { load "irb/cmd/help.rb" }
791-
end
792-
793787
def test_show_doc
794788
out, err = execute_lines(
795789
"show_doc String#gsub\n",

0 commit comments

Comments
 (0)