Skip to content

Commit 7e85765

Browse files
authored
Add "show_cmds" command to list all commands' descriptions (#463)
1 parent f210b8a commit 7e85765

25 files changed

+182
-17
lines changed

lib/irb/cmd/backtrace.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ module IRB
66
# :stopdoc:
77

88
module ExtendCommand
9-
class Backtrace < Debug
9+
class Backtrace < DebugCommand
1010
def self.transform_args(args)
1111
args&.dump
1212
end

lib/irb/cmd/break.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ module IRB
66
# :stopdoc:
77

88
module ExtendCommand
9-
class Break < Debug
9+
class Break < DebugCommand
1010
def self.transform_args(args)
1111
args&.dump
1212
end

lib/irb/cmd/catch.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ module IRB
66
# :stopdoc:
77

88
module ExtendCommand
9-
class Catch < Debug
9+
class Catch < DebugCommand
1010
def self.transform_args(args)
1111
args&.dump
1212
end

lib/irb/cmd/chws.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,18 @@ module IRB
1919
module ExtendCommand
2020

2121
class CurrentWorkingWorkspace < Nop
22+
category "IRB"
23+
description "Show the current workspace."
24+
2225
def execute(*obj)
2326
irb_context.main
2427
end
2528
end
2629

2730
class ChangeWorkspace < Nop
31+
category "IRB"
32+
description "Change the current workspace to an object."
33+
2834
def execute(*obj)
2935
irb_context.change_workspace(*obj)
3036
irb_context.main

lib/irb/cmd/continue.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ module IRB
66
# :stopdoc:
77

88
module ExtendCommand
9-
class Continue < Debug
9+
class Continue < DebugCommand
1010
def execute(*args)
1111
super(do_cmds: ["continue", *args].join(" "))
1212
end

lib/irb/cmd/debug.rb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ module IRB
55

66
module ExtendCommand
77
class Debug < Nop
8+
category "Debugging"
9+
description "Start the debugger of debug.gem."
10+
811
BINDING_IRB_FRAME_REGEXPS = [
912
'<internal:prelude>',
1013
binding.method(:irb).source_location.first,
@@ -108,5 +111,16 @@ def load_bundled_debug_gem
108111
end
109112
end
110113
end
114+
115+
class DebugCommand < Debug
116+
def self.category
117+
"Debugging"
118+
end
119+
120+
def self.description
121+
command_name = self.name.split("::").last.downcase
122+
"Start the debugger of debug.gem and run its `#{command_name}` command."
123+
end
124+
end
111125
end
112126
end

lib/irb/cmd/delete.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ module IRB
66
# :stopdoc:
77

88
module ExtendCommand
9-
class Delete < Debug
9+
class Delete < DebugCommand
1010
def execute(*args)
1111
super(pre_cmds: ["delete", *args].join(" "))
1212
end

lib/irb/cmd/edit.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ module IRB
66

77
module ExtendCommand
88
class Edit < Nop
9+
category "Misc"
10+
description 'Open a file with the editor command defined with `ENV["EDITOR"]`.'
11+
912
class << self
1013
def transform_args(args)
1114
# Return a string literal as is for backward compatibility

lib/irb/cmd/finish.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ module IRB
66
# :stopdoc:
77

88
module ExtendCommand
9-
class Finish < Debug
9+
class Finish < DebugCommand
1010
def execute(*args)
1111
super(do_cmds: ["finish", *args].join(" "))
1212
end

lib/irb/cmd/help.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ module IRB
1616

1717
module ExtendCommand
1818
class Help < Nop
19+
category "Context"
20+
description "Enter the mode to look up RI documents."
21+
1922
def execute(*names)
2023
require 'rdoc/ri/driver'
2124
opts = RDoc::RI::Driver.process_args([])

0 commit comments

Comments
 (0)