irb 1.5.1 → 1.6.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e7dc14606c6de90f8f56048a7ec6f8ca2bc83a8d4e0aa50d60dbe84141389601
4
- data.tar.gz: bca1a92ee2088e483073d48dd9e0b3cdbf9b8d67768ed3fd922bb7e91da68039
3
+ metadata.gz: 2df1f78bfd3e28e4102262fc4b9011d6c84c7690cba11f870e6e9f54e8718ebe
4
+ data.tar.gz: 20d55eba407c974060b73fc4ba741d534da8f933f65ec1bb03e85ba36129dc01
5
5
  SHA512:
6
- metadata.gz: b44c813a4fc0010423d0e7ac189dc264ea92587db1b05e16e6c8ec49ff20bc2b4c18b5cfa454543b7d894be0b6610c96a3bf17b85b31d9083d962665063c8a85
7
- data.tar.gz: af7f077aa6b2c67ccbe67209a35e622bff087a28615b3086a0511188da1b09d2284b662d659d3b308bf251488547aeaecf9da2b29454c2031d52c0e902ba7889
6
+ metadata.gz: a829406c154fb4cb7d877ebe95bfb8ab20dd894e6adaaa4fd05ee198740f2deff0a449c469ff1c388075424b04ecd28db6bb3298c345c46b9c821ffb8f1d4ad4
7
+ data.tar.gz: 0fde56ad653b34522edcc1f9d5f8d2524ced3551b1f1f3ff1b99226b8263433b27c416b10121ae6fdeb2ed82541341fe6dfd8e8e1ff712d01e3c32d69b6707b6
data/Gemfile CHANGED
@@ -11,5 +11,5 @@ group :development do
11
11
  gem "stackprof" if is_unix && !is_truffleruby
12
12
  gem "test-unit"
13
13
  gem "reline", github: "ruby/reline" if ENV["WITH_LATEST_RELINE"] == "true"
14
- gem "debug"
14
+ gem "debug", github: "ruby/debug"
15
15
  end
data/README.md CHANGED
@@ -42,56 +42,57 @@ The Readline extension module can be used with irb. Use of Readline is default i
42
42
 
43
43
  ## Commands
44
44
 
45
- The following commands are available on IRB.
46
-
47
- * `cwws`
48
- * Show the current workspace.
49
- * `cb`, `cws`, `chws`
50
- * Change the current workspace to an object.
51
- * `bindings`, `workspaces`
52
- * Show workspaces.
53
- * `edit`
54
- * Open a file with the editor command defined with `ENV["EDITOR"]`
55
- * `edit` - opens the file the current context belongs to (if applicable)
56
- * `edit foo.rb` - opens `foo.rb`
57
- * `edit Foo` - opens the location of `Foo`
58
- * `edit Foo.bar` - opens the location of `Foo.bar`
59
- * `edit Foo#bar` - opens the location of `Foo#bar`
60
- * `pushb`, `pushws`
61
- * Push an object to the workspace stack.
62
- * `popb`, `popws`
63
- * Pop a workspace from the workspace stack.
64
- * `load`
65
- * Load a Ruby file.
66
- * `require`
67
- * Require a Ruby file.
68
- * `source`
69
- * Loads a given file in the current session.
70
- * `irb`
71
- * Start a child IRB.
72
- * `jobs`
73
- * List of current sessions.
74
- * `fg`
75
- * Switches to the session of the given number.
76
- * `kill`
77
- * Kills the session with the given number.
78
- * `help`
79
- * Enter the mode to look up RI documents.
80
- * `irb_info`
81
- * Show information about IRB.
82
- * `ls`
83
- * Show methods, constants, and variables.
84
- `-g [query]` or `-G [query]` allows you to filter out the output.
85
- * `measure`
86
- * `measure` enables the mode to measure processing time. `measure :off` disables it.
87
- * `$`, `show_source`
88
- * Show the source code of a given method or constant.
89
- * `@`, `whereami`
90
- * Show the source code around binding.irb again.
91
- * `debug`
92
- * Start the debugger of debug.gem.
93
- * `break`, `delete`, `next`, `step`, `continue`, `finish`, `backtrace`, `info`, `catch`
94
- * Start the debugger of debug.gem and run the command on it.
45
+ The following commands are available on IRB. You can get the same output from the `show_cmds` command.
46
+
47
+
48
+ ```
49
+ IRB
50
+ cwws Show the current workspace.
51
+ chws Change the current workspace to an object.
52
+ workspaces Show workspaces.
53
+ pushws Push an object to the workspace stack.
54
+ popws Pop a workspace from the workspace stack.
55
+ irb_load Load a Ruby file.
56
+ irb_require Require a Ruby file.
57
+ source Loads a given file in the current session.
58
+ irb Start a child IRB.
59
+ jobs List of current sessions.
60
+ fg Switches to the session of the given number.
61
+ kill Kills the session with the given number.
62
+ irb_info Show information about IRB.
63
+ show_cmds List all available commands and their description.
64
+
65
+ Debugging
66
+ debug Start the debugger of debug.gem.
67
+ break Start the debugger of debug.gem and run its `break` command.
68
+ catch Start the debugger of debug.gem and run its `catch` command.
69
+ next Start the debugger of debug.gem and run its `next` command.
70
+ delete Start the debugger of debug.gem and run its `delete` command.
71
+ step Start the debugger of debug.gem and run its `step` command.
72
+ continue Start the debugger of debug.gem and run its `continue` command.
73
+ finish Start the debugger of debug.gem and run its `finish` command.
74
+ backtrace Start the debugger of debug.gem and run its `backtrace` command.
75
+ info Start the debugger of debug.gem and run its `info` command.
76
+
77
+ Misc
78
+ edit Open a file with the editor command defined with `ENV["EDITOR"]`.
79
+ measure `measure` enables the mode to measure processing time. `measure :off` disables it.
80
+
81
+ Context
82
+ show_doc Enter the mode to look up RI documents.
83
+ ls Show methods, constants, and variables. `-g [query]` or `-G [query]` allows you to filter out the output.
84
+ show_source Show the source code of a given method or constant.
85
+ whereami Show the source code around binding.irb again.
86
+ ```
87
+
88
+ ## Configuration
89
+
90
+ ### Environment Variables
91
+
92
+ - `NO_COLOR`: Assigning a value to it disables IRB's colorization.
93
+ - `IRB_USE_AUTOCOMPLETE`: Setting it to `false` disables IRB's autocompletion.
94
+ - `EDITOR`: Its value would be used to open files by the `edit` command.
95
+ - `IRBRC`: The file specified would be evaluated as IRB's rc-file.
95
96
 
96
97
  ## Documentation
97
98
 
@@ -6,7 +6,7 @@ module IRB
6
6
  # :stopdoc:
7
7
 
8
8
  module ExtendCommand
9
- class Backtrace < Debug
9
+ class Backtrace < DebugCommand
10
10
  def self.transform_args(args)
11
11
  args&.dump
12
12
  end
data/lib/irb/cmd/break.rb CHANGED
@@ -6,7 +6,7 @@ module IRB
6
6
  # :stopdoc:
7
7
 
8
8
  module ExtendCommand
9
- class Break < Debug
9
+ class Break < DebugCommand
10
10
  def self.transform_args(args)
11
11
  args&.dump
12
12
  end
data/lib/irb/cmd/catch.rb CHANGED
@@ -6,7 +6,7 @@ module IRB
6
6
  # :stopdoc:
7
7
 
8
8
  module ExtendCommand
9
- class Catch < Debug
9
+ class Catch < DebugCommand
10
10
  def self.transform_args(args)
11
11
  args&.dump
12
12
  end
data/lib/irb/cmd/chws.rb CHANGED
@@ -19,12 +19,18 @@ module IRB
19
19
  module ExtendCommand
20
20
 
21
21
  class CurrentWorkingWorkspace < Nop
22
+ category "IRB"
23
+ description "Show the current workspace."
24
+
22
25
  def execute(*obj)
23
26
  irb_context.main
24
27
  end
25
28
  end
26
29
 
27
30
  class ChangeWorkspace < Nop
31
+ category "IRB"
32
+ description "Change the current workspace to an object."
33
+
28
34
  def execute(*obj)
29
35
  irb_context.change_workspace(*obj)
30
36
  irb_context.main
@@ -6,7 +6,7 @@ module IRB
6
6
  # :stopdoc:
7
7
 
8
8
  module ExtendCommand
9
- class Continue < Debug
9
+ class Continue < DebugCommand
10
10
  def execute(*args)
11
11
  super(do_cmds: ["continue", *args].join(" "))
12
12
  end
data/lib/irb/cmd/debug.rb CHANGED
@@ -5,6 +5,9 @@ module IRB
5
5
 
6
6
  module ExtendCommand
7
7
  class Debug < Nop
8
+ category "Debugging"
9
+ description "Start the debugger of debug.gem."
10
+
8
11
  BINDING_IRB_FRAME_REGEXPS = [
9
12
  '<internal:prelude>',
10
13
  binding.method(:irb).source_location.first,
@@ -108,5 +111,16 @@ module IRB
108
111
  end
109
112
  end
110
113
  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
111
125
  end
112
126
  end
@@ -6,7 +6,7 @@ module IRB
6
6
  # :stopdoc:
7
7
 
8
8
  module ExtendCommand
9
- class Delete < Debug
9
+ class Delete < DebugCommand
10
10
  def execute(*args)
11
11
  super(pre_cmds: ["delete", *args].join(" "))
12
12
  end
data/lib/irb/cmd/edit.rb CHANGED
@@ -6,6 +6,9 @@ module IRB
6
6
 
7
7
  module ExtendCommand
8
8
  class Edit < Nop
9
+ category "Misc"
10
+ description 'Open a file with the editor command defined with `ENV["EDITOR"]`.'
11
+
9
12
  class << self
10
13
  def transform_args(args)
11
14
  # Return a string literal as is for backward compatibility
@@ -6,7 +6,7 @@ module IRB
6
6
  # :stopdoc:
7
7
 
8
8
  module ExtendCommand
9
- class Finish < Debug
9
+ class Finish < DebugCommand
10
10
  def execute(*args)
11
11
  super(do_cmds: ["finish", *args].join(" "))
12
12
  end
data/lib/irb/cmd/help.rb CHANGED
@@ -16,6 +16,9 @@ module IRB
16
16
 
17
17
  module ExtendCommand
18
18
  class Help < Nop
19
+ category "Context"
20
+ description "Enter the mode to look up RI documents."
21
+
19
22
  def execute(*names)
20
23
  require 'rdoc/ri/driver'
21
24
  opts = RDoc::RI::Driver.process_args([])
data/lib/irb/cmd/info.rb CHANGED
@@ -6,7 +6,7 @@ module IRB
6
6
  # :stopdoc:
7
7
 
8
8
  module ExtendCommand
9
- class Info < Debug
9
+ class Info < DebugCommand
10
10
  def self.transform_args(args)
11
11
  args&.dump
12
12
  end
@@ -7,6 +7,9 @@ module IRB
7
7
 
8
8
  module ExtendCommand
9
9
  class IrbInfo < Nop
10
+ category "IRB"
11
+ description "Show information about IRB."
12
+
10
13
  def execute
11
14
  Class.new {
12
15
  def inspect
data/lib/irb/cmd/load.rb CHANGED
@@ -17,18 +17,29 @@ module IRB
17
17
  # :stopdoc:
18
18
 
19
19
  module ExtendCommand
20
- class Load < Nop
20
+ class LoaderCommand < Nop
21
21
  include IrbLoader
22
22
 
23
- def execute(file_name, priv = nil)
24
- return irb_load(file_name, priv)
23
+ def raise_cmd_argument_error
24
+ raise CommandArgumentError.new("Please specify the file name.")
25
25
  end
26
26
  end
27
27
 
28
- class Require < Nop
29
- include IrbLoader
28
+ class Load < LoaderCommand
29
+ category "IRB"
30
+ description "Load a Ruby file."
31
+
32
+ def execute(file_name = nil, priv = nil)
33
+ raise_cmd_argument_error unless file_name
34
+ irb_load(file_name, priv)
35
+ end
36
+ end
30
37
 
31
- def execute(file_name)
38
+ class Require < LoaderCommand
39
+ category "IRB"
40
+ description "Require a Ruby file."
41
+ def execute(file_name = nil)
42
+ raise_cmd_argument_error unless file_name
32
43
 
33
44
  rex = Regexp.new("#{Regexp.quote(file_name)}(\.o|\.rb)?")
34
45
  return false if $".find{|f| f =~ rex}
@@ -56,13 +67,16 @@ module IRB
56
67
  end
57
68
  end
58
69
 
59
- class Source < Nop
60
- include IrbLoader
61
- def execute(file_name)
70
+ class Source < LoaderCommand
71
+ category "IRB"
72
+ description "Loads a given file in the current session."
73
+
74
+ def execute(file_name = nil)
75
+ raise_cmd_argument_error unless file_name
76
+
62
77
  source_file(file_name)
63
78
  end
64
79
  end
65
80
  end
66
-
67
81
  # :startdoc:
68
82
  end
data/lib/irb/cmd/ls.rb CHANGED
@@ -9,6 +9,9 @@ module IRB
9
9
 
10
10
  module ExtendCommand
11
11
  class Ls < Nop
12
+ category "Context"
13
+ description "Show methods, constants, and variables. `-g [query]` or `-G [query]` allows you to filter out the output."
14
+
12
15
  def self.transform_args(args)
13
16
  if match = args&.match(/\A(?<args>.+\s|)(-g|-G)\s+(?<grep>[^\s]+)\s*\n\z/)
14
17
  args = match[:args]
@@ -30,6 +33,7 @@ module IRB
30
33
  o.dump("instance variables", obj.instance_variables)
31
34
  o.dump("class variables", klass.class_variables)
32
35
  o.dump("locals", locals)
36
+ nil
33
37
  end
34
38
 
35
39
  def dump_methods(o, klass, obj)
@@ -5,6 +5,9 @@ module IRB
5
5
 
6
6
  module ExtendCommand
7
7
  class Measure < Nop
8
+ category "Misc"
9
+ description "`measure` enables the mode to measure processing time. `measure :off` disables it."
10
+
8
11
  def initialize(*args)
9
12
  super(*args)
10
13
  end
data/lib/irb/cmd/next.rb CHANGED
@@ -6,7 +6,7 @@ module IRB
6
6
  # :stopdoc:
7
7
 
8
8
  module ExtendCommand
9
- class Next < Debug
9
+ class Next < DebugCommand
10
10
  def execute(*args)
11
11
  super(do_cmds: ["next", *args].join(" "))
12
12
  end
data/lib/irb/cmd/nop.rb CHANGED
@@ -13,17 +13,34 @@ module IRB
13
13
  # :stopdoc:
14
14
 
15
15
  module ExtendCommand
16
+ class CommandArgumentError < StandardError; end
17
+
16
18
  class Nop
19
+ class << self
20
+ def category(category = nil)
21
+ @category = category if category
22
+ @category
23
+ end
24
+
25
+ def description(description = nil)
26
+ @description = description if description
27
+ @description
28
+ end
29
+ end
17
30
 
18
31
  if RUBY_ENGINE == "ruby" && RUBY_VERSION >= "2.7.0"
19
32
  def self.execute(conf, *opts, **kwargs, &block)
20
33
  command = new(conf)
21
34
  command.execute(*opts, **kwargs, &block)
35
+ rescue CommandArgumentError => e
36
+ puts e.message
22
37
  end
23
38
  else
24
39
  def self.execute(conf, *opts, &block)
25
40
  command = new(conf)
26
41
  command.execute(*opts, &block)
42
+ rescue CommandArgumentError => e
43
+ puts e.message
27
44
  end
28
45
  end
29
46
 
@@ -18,12 +18,18 @@ module IRB
18
18
 
19
19
  module ExtendCommand
20
20
  class Workspaces < Nop
21
+ category "IRB"
22
+ description "Show workspaces."
23
+
21
24
  def execute(*obj)
22
25
  irb_context.workspaces.collect{|ws| ws.main}
23
26
  end
24
27
  end
25
28
 
26
29
  class PushWorkspace < Workspaces
30
+ category "IRB"
31
+ description "Push an object to the workspace stack."
32
+
27
33
  def execute(*obj)
28
34
  irb_context.push_workspace(*obj)
29
35
  super
@@ -31,6 +37,9 @@ module IRB
31
37
  end
32
38
 
33
39
  class PopWorkspace < Workspaces
40
+ category "IRB"
41
+ description "Pop a workspace from the workspace stack."
42
+
34
43
  def execute(*obj)
35
44
  irb_context.pop_workspace(*obj)
36
45
  super
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "stringio"
4
+ require_relative "nop"
5
+
6
+ module IRB
7
+ # :stopdoc:
8
+
9
+ module ExtendCommand
10
+ class ShowCmds < Nop
11
+ category "IRB"
12
+ description "List all available commands and their description."
13
+
14
+ def execute(*args)
15
+ commands_info = IRB::ExtendCommandBundle.all_commands_info
16
+ commands_grouped_by_categories = commands_info.group_by { |cmd| cmd[:category] }
17
+ longest_cmd_name_length = commands_info.map { |c| c[:display_name] }.max { |a, b| a.length <=> b.length }.length
18
+
19
+ output = StringIO.new
20
+
21
+ commands_grouped_by_categories.each do |category, cmds|
22
+ output.puts Color.colorize(category, [:BOLD])
23
+
24
+ cmds.each do |cmd|
25
+ output.puts " #{cmd[:display_name].to_s.ljust(longest_cmd_name_length)} #{cmd[:description]}"
26
+ end
27
+
28
+ output.puts
29
+ end
30
+
31
+ puts output.string
32
+
33
+ nil
34
+ end
35
+ end
36
+ end
37
+
38
+ # :startdoc:
39
+ end
@@ -9,6 +9,9 @@ module IRB
9
9
 
10
10
  module ExtendCommand
11
11
  class ShowSource < Nop
12
+ category "Context"
13
+ description "Show the source code of a given method or constant."
14
+
12
15
  class << self
13
16
  def transform_args(args)
14
17
  # Return a string literal as is for backward compatibility
data/lib/irb/cmd/step.rb CHANGED
@@ -6,7 +6,7 @@ module IRB
6
6
  # :stopdoc:
7
7
 
8
8
  module ExtendCommand
9
- class Step < Debug
9
+ class Step < DebugCommand
10
10
  def execute(*args)
11
11
  # Run `next` first to move out of binding.irb
12
12
  super(pre_cmds: "next", do_cmds: ["step", *args].join(" "))
@@ -10,31 +10,57 @@
10
10
  #
11
11
 
12
12
  require_relative "nop"
13
- require_relative "../ext/multi-irb"
14
13
 
15
14
  module IRB
16
15
  # :stopdoc:
17
16
 
18
17
  module ExtendCommand
19
- class IrbCommand < Nop
18
+ class MultiIRBCommand < Nop
19
+ def initialize(conf)
20
+ super
21
+ extend_irb_context
22
+ end
23
+
24
+ private
25
+
26
+ def extend_irb_context
27
+ # this extension patches IRB context like IRB.CurrentContext
28
+ require_relative "../ext/multi-irb"
29
+ end
30
+ end
31
+
32
+ class IrbCommand < MultiIRBCommand
33
+ category "IRB"
34
+ description "Start a child IRB."
35
+
20
36
  def execute(*obj)
21
37
  IRB.irb(nil, *obj)
22
38
  end
23
39
  end
24
40
 
25
- class Jobs < Nop
41
+ class Jobs < MultiIRBCommand
42
+ category "IRB"
43
+ description "List of current sessions."
44
+
26
45
  def execute
27
46
  IRB.JobManager
28
47
  end
29
48
  end
30
49
 
31
- class Foreground < Nop
32
- def execute(key)
50
+ class Foreground < MultiIRBCommand
51
+ category "IRB"
52
+ description "Switches to the session of the given number."
53
+
54
+ def execute(key = nil)
55
+ raise CommandArgumentError.new("Please specify the id of target IRB job (listed in the `jobs` command).") unless key
33
56
  IRB.JobManager.switch(key)
34
57
  end
35
58
  end
36
59
 
37
- class Kill < Nop
60
+ class Kill < MultiIRBCommand
61
+ category "IRB"
62
+ description "Kills the session with the given number."
63
+
38
64
  def execute(*keys)
39
65
  IRB.JobManager.kill(*keys)
40
66
  end
@@ -7,6 +7,9 @@ module IRB
7
7
 
8
8
  module ExtendCommand
9
9
  class Whereami < Nop
10
+ category "Context"
11
+ description "Show the source code around binding.irb again."
12
+
10
13
  def execute(*)
11
14
  code = irb_context.workspace.code_around_binding
12
15
  if code
@@ -70,7 +70,7 @@ module IRB
70
70
  end
71
71
  history_file = IRB.rc_file("_history") unless history_file
72
72
  if File.exist?(history_file)
73
- open(history_file, "r:#{IRB.conf[:LC_MESSAGES].encoding}") do |f|
73
+ File.open(history_file, "r:#{IRB.conf[:LC_MESSAGES].encoding}") do |f|
74
74
  f.each { |l|
75
75
  l = l.chomp
76
76
  if self.class == RelineInputMethod and history.last&.end_with?("\\")
@@ -45,14 +45,15 @@ module IRB # :nodoc:
45
45
  [:quit, :irb_exit, OVERRIDE_PRIVATE_ONLY],
46
46
  ]
47
47
 
48
+
48
49
  @EXTEND_COMMANDS = [
49
50
  [
50
51
  :irb_current_working_workspace, :CurrentWorkingWorkspace, "cmd/chws",
52
+ [:cwws, NO_OVERRIDE],
53
+ [:pwws, NO_OVERRIDE],
51
54
  [:irb_print_working_workspace, OVERRIDE_ALL],
52
55
  [:irb_cwws, OVERRIDE_ALL],
53
56
  [:irb_pwws, OVERRIDE_ALL],
54
- [:cwws, NO_OVERRIDE],
55
- [:pwws, NO_OVERRIDE],
56
57
  [:irb_current_working_binding, OVERRIDE_ALL],
57
58
  [:irb_print_working_binding, OVERRIDE_ALL],
58
59
  [:irb_cwb, OVERRIDE_ALL],
@@ -60,10 +61,10 @@ module IRB # :nodoc:
60
61
  ],
61
62
  [
62
63
  :irb_change_workspace, :ChangeWorkspace, "cmd/chws",
63
- [:irb_chws, OVERRIDE_ALL],
64
- [:irb_cws, OVERRIDE_ALL],
65
64
  [:chws, NO_OVERRIDE],
66
65
  [:cws, NO_OVERRIDE],
66
+ [:irb_chws, OVERRIDE_ALL],
67
+ [:irb_cws, OVERRIDE_ALL],
67
68
  [:irb_change_binding, OVERRIDE_ALL],
68
69
  [:irb_cb, OVERRIDE_ALL],
69
70
  [:cb, NO_OVERRIDE],
@@ -77,16 +78,16 @@ module IRB # :nodoc:
77
78
  ],
78
79
  [
79
80
  :irb_push_workspace, :PushWorkspace, "cmd/pushws",
80
- [:irb_pushws, OVERRIDE_ALL],
81
81
  [:pushws, NO_OVERRIDE],
82
+ [:irb_pushws, OVERRIDE_ALL],
82
83
  [:irb_push_binding, OVERRIDE_ALL],
83
84
  [:irb_pushb, OVERRIDE_ALL],
84
85
  [:pushb, NO_OVERRIDE],
85
86
  ],
86
87
  [
87
88
  :irb_pop_workspace, :PopWorkspace, "cmd/pushws",
88
- [:irb_popws, OVERRIDE_ALL],
89
89
  [:popws, NO_OVERRIDE],
90
+ [:irb_popws, OVERRIDE_ALL],
90
91
  [:irb_pop_binding, OVERRIDE_ALL],
91
92
  [:irb_popb, OVERRIDE_ALL],
92
93
  [:popb, NO_OVERRIDE],
@@ -131,7 +132,7 @@ module IRB # :nodoc:
131
132
  :irb_catch, :Catch, "cmd/catch",
132
133
  ],
133
134
  [
134
- :irb_next, :Next, "cmd/next",
135
+ :irb_next, :Next, "cmd/next"
135
136
  ],
136
137
  [
137
138
  :irb_delete, :Delete, "cmd/delete",
@@ -161,6 +162,7 @@ module IRB # :nodoc:
161
162
 
162
163
  [
163
164
  :irb_help, :Help, "cmd/help",
165
+ [:show_doc, NO_OVERRIDE],
164
166
  [:help, NO_OVERRIDE],
165
167
  ],
166
168
 
@@ -187,9 +189,41 @@ module IRB # :nodoc:
187
189
  :irb_whereami, :Whereami, "cmd/whereami",
188
190
  [:whereami, NO_OVERRIDE],
189
191
  ],
190
-
192
+ [
193
+ :irb_show_cmds, :ShowCmds, "cmd/show_cmds",
194
+ [:show_cmds, NO_OVERRIDE],
195
+ ]
191
196
  ]
192
197
 
198
+
199
+ @@commands = []
200
+
201
+ def self.all_commands_info
202
+ return @@commands unless @@commands.empty?
203
+ user_aliases = IRB.CurrentContext.command_aliases.each_with_object({}) do |(alias_name, target), result|
204
+ result[target] ||= []
205
+ result[target] << alias_name
206
+ end
207
+
208
+ @EXTEND_COMMANDS.each do |cmd_name, cmd_class, load_file, *aliases|
209
+ if !defined?(ExtendCommand) || !ExtendCommand.const_defined?(cmd_class, false)
210
+ require_relative load_file
211
+ end
212
+
213
+ klass = ExtendCommand.const_get(cmd_class, false)
214
+ aliases = aliases.map { |a| a.first }
215
+
216
+ if additional_aliases = user_aliases[cmd_name]
217
+ aliases += additional_aliases
218
+ end
219
+
220
+ display_name = aliases.shift || cmd_name
221
+ @@commands << { display_name: display_name, description: klass.description, category: klass.category }
222
+ end
223
+
224
+ @@commands
225
+ end
226
+
193
227
  # Convert a command name to its implementation class if such command exists
194
228
  def self.load_command(command)
195
229
  command = command.to_sym
data/lib/irb/init.rb CHANGED
@@ -45,7 +45,7 @@ module IRB # :nodoc:
45
45
 
46
46
  @CONF[:USE_SINGLELINE] = false unless defined?(ReadlineInputMethod)
47
47
  @CONF[:USE_COLORIZE] = (nc = ENV['NO_COLOR']).nil? || nc.empty?
48
- @CONF[:USE_AUTOCOMPLETE] = true
48
+ @CONF[:USE_AUTOCOMPLETE] = ENV.fetch("IRB_USE_AUTOCOMPLETE", "true") != "false"
49
49
  @CONF[:INSPECT_MODE] = true
50
50
  @CONF[:USE_TRACER] = false
51
51
  @CONF[:USE_LOADER] = false
data/lib/irb/version.rb CHANGED
@@ -11,7 +11,7 @@
11
11
  #
12
12
 
13
13
  module IRB # :nodoc:
14
- VERSION = "1.5.1"
14
+ VERSION = "1.6.0"
15
15
  @RELEASE_VERSION = VERSION
16
16
  @LAST_UPDATE_DATE = "2022-11-28"
17
17
  end
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: irb
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.1
4
+ version: 1.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - aycabta
8
8
  - Keiju ISHITSUKA
9
- autorequire:
9
+ autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2022-11-28 00:00:00.000000000 Z
12
+ date: 2022-12-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: reline
@@ -65,6 +65,7 @@ files:
65
65
  - lib/irb/cmd/next.rb
66
66
  - lib/irb/cmd/nop.rb
67
67
  - lib/irb/cmd/pushws.rb
68
+ - lib/irb/cmd/show_cmds.rb
68
69
  - lib/irb/cmd/show_source.rb
69
70
  - lib/irb/cmd/step.rb
70
71
  - lib/irb/cmd/subirb.rb
@@ -110,7 +111,7 @@ licenses:
110
111
  - Ruby
111
112
  - BSD-2-Clause
112
113
  metadata: {}
113
- post_install_message:
114
+ post_install_message:
114
115
  rdoc_options: []
115
116
  require_paths:
116
117
  - lib
@@ -126,7 +127,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
126
127
  version: '0'
127
128
  requirements: []
128
129
  rubygems_version: 3.3.26
129
- signing_key:
130
+ signing_key:
130
131
  specification_version: 4
131
132
  summary: Interactive Ruby command-line tool for REPL (Read Eval Print Loop).
132
133
  test_files: []