irb 1.11.1 → 1.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +3 -0
  3. data/README.md +11 -9
  4. data/Rakefile +1 -1
  5. data/lib/irb/cmd/nop.rb +3 -52
  6. data/lib/irb/{cmd → command}/backtrace.rb +1 -1
  7. data/lib/irb/command/base.rb +64 -0
  8. data/lib/irb/{cmd → command}/break.rb +1 -1
  9. data/lib/irb/{cmd → command}/catch.rb +1 -1
  10. data/lib/irb/{cmd → command}/chws.rb +4 -6
  11. data/lib/irb/{cmd → command}/continue.rb +1 -1
  12. data/lib/irb/{cmd → command}/debug.rb +3 -4
  13. data/lib/irb/{cmd → command}/delete.rb +1 -1
  14. data/lib/irb/command/edit.rb +70 -0
  15. data/lib/irb/{cmd → command}/exit.rb +2 -4
  16. data/lib/irb/{cmd → command}/finish.rb +1 -1
  17. data/lib/irb/command/force_exit.rb +20 -0
  18. data/lib/irb/command/help.rb +84 -0
  19. data/lib/irb/{cmd → command}/history.rb +3 -3
  20. data/lib/irb/{cmd → command}/info.rb +1 -1
  21. data/lib/irb/{cmd → command}/irb_info.rb +5 -6
  22. data/lib/irb/{cmd → command}/load.rb +3 -5
  23. data/lib/irb/{cmd → command}/ls.rb +10 -4
  24. data/lib/irb/{cmd → command}/measure.rb +2 -4
  25. data/lib/irb/{cmd → command}/next.rb +1 -1
  26. data/lib/irb/{cmd → command}/pushws.rb +20 -5
  27. data/lib/irb/{cmd → command}/show_doc.rb +17 -5
  28. data/lib/irb/{cmd → command}/show_source.rb +26 -10
  29. data/lib/irb/{cmd → command}/step.rb +1 -1
  30. data/lib/irb/{cmd → command}/subirb.rb +3 -5
  31. data/lib/irb/{cmd → command}/whereami.rb +2 -4
  32. data/lib/irb/{extend-command.rb → command.rb} +50 -86
  33. data/lib/irb/completion.rb +1 -1
  34. data/lib/irb/context.rb +63 -20
  35. data/lib/irb/ext/change-ws.rb +4 -4
  36. data/lib/irb/ext/eval_history.rb +3 -3
  37. data/lib/irb/ext/loader.rb +4 -4
  38. data/lib/irb/ext/multi-irb.rb +1 -1
  39. data/lib/irb/ext/tracer.rb +12 -51
  40. data/lib/irb/ext/use-loader.rb +6 -8
  41. data/lib/irb/ext/workspaces.rb +11 -34
  42. data/lib/irb/frame.rb +1 -1
  43. data/lib/irb/help.rb +1 -1
  44. data/lib/irb/history.rb +12 -4
  45. data/lib/irb/init.rb +28 -17
  46. data/lib/irb/input-method.rb +18 -2
  47. data/lib/irb/inspector.rb +3 -3
  48. data/lib/irb/lc/error.rb +1 -6
  49. data/lib/irb/lc/ja/error.rb +1 -6
  50. data/lib/irb/locale.rb +2 -2
  51. data/lib/irb/nesting_parser.rb +13 -3
  52. data/lib/irb/notifier.rb +1 -1
  53. data/lib/irb/output-method.rb +2 -8
  54. data/lib/irb/ruby-lex.rb +2 -2
  55. data/lib/irb/source_finder.rb +98 -38
  56. data/lib/irb/statement.rb +25 -3
  57. data/lib/irb/version.rb +3 -3
  58. data/lib/irb/workspace.rb +4 -4
  59. data/lib/irb/ws-for-case-2.rb +1 -1
  60. data/lib/irb/xmp.rb +1 -1
  61. data/lib/irb.rb +38 -32
  62. metadata +30 -29
  63. data/lib/irb/cmd/edit.rb +0 -60
  64. data/lib/irb/cmd/help.rb +0 -23
  65. data/lib/irb/cmd/show_cmds.rb +0 -59
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 17969636013c03ffd08d5b53570ec0eda8620855092bd863c5b851e668343007
4
- data.tar.gz: 7900a886588ebca5839e2b6fac6d538e58febd2706cdbbe979e098f2950d2d79
3
+ metadata.gz: 4ef257bd1b4917c3af8f4e1c372cb7c489cd16844df518e352c0bff74c77b4fc
4
+ data.tar.gz: e9cd328330de9c415b93f680228ff79c3a798c481fe657bc48f7d7305470462c
5
5
  SHA512:
6
- metadata.gz: e9d8fe7568718ce10db38ed1a85ad92473c21ca81738cadaa8a8258adcf18cdbfc5755c61621c336ac4bc53c57a08ad26311a4fc671fb98ad0cd5130c2e7527e
7
- data.tar.gz: 729f6a0f6ba9fe6cfac3e2ed9e752531006f60c386b3e51fd84c877eeb1b3cdcb0fee1a7bf44c3c0bfa7f0f56def8ad8c7d99413b9b96b304d17e0c15d90aa87
6
+ metadata.gz: 78b5b33588812cda49274b45e7b905cec8cb9e6b0ed71be66a644680db5ac96a19e276952425ec54a05d2ce3e8cf99b69eb7964e310770e155ced4f51501b088
7
+ data.tar.gz: 68ae7b61704a3356a14d526bdf058306c9ef158d8442030779b9256a59bee2929e1bab1fdf394f39bda09479b47430ca1de94c57c7b23017affec1400975e03a
data/Gemfile CHANGED
@@ -17,6 +17,9 @@ gem "rake"
17
17
  gem "test-unit"
18
18
  gem "test-unit-ruby-core"
19
19
 
20
+ gem "rubocop"
21
+
22
+ gem "tracer" if !is_truffleruby
20
23
  gem "debug", github: "ruby/debug", platforms: [:mri, :mswin]
21
24
 
22
25
  if RUBY_VERSION >= "3.0.0" && !is_truffleruby
data/README.md CHANGED
@@ -30,7 +30,7 @@ The `irb` command from your shell will start the interpreter.
30
30
 
31
31
  ## Installation
32
32
 
33
- > **Note**
33
+ > [!Note]
34
34
  >
35
35
  > IRB is a default gem of Ruby so you shouldn't need to install it separately.
36
36
  >
@@ -56,7 +56,7 @@ $ gem install irb
56
56
 
57
57
  ## Usage
58
58
 
59
- > **Note**
59
+ > [!Note]
60
60
  >
61
61
  > We're working hard to match Pry's variety of powerful features in IRB, and you can track our progress or find contribution ideas in [this document](https://github.com/ruby/irb/blob/master/COMPARED_WITH_PRY.md).
62
62
 
@@ -107,16 +107,19 @@ Hello World
107
107
 
108
108
  ## Commands
109
109
 
110
- The following commands are available on IRB. You can get the same output from the `show_cmds` command.
110
+ The following commands are available on IRB. You can get the same output from the `help` command.
111
111
 
112
112
  ```txt
113
+ Help
114
+ help List all available commands. Use `help <command>` to get information about a specific command.
115
+
113
116
  IRB
114
117
  exit Exit the current irb session.
118
+ exit! Exit the current process.
115
119
  irb_load Load a Ruby file.
116
120
  irb_require Require a Ruby file.
117
121
  source Loads a given file in the current session.
118
122
  irb_info Show information about IRB.
119
- show_cmds List all available commands and their description.
120
123
  history Shows the input history. `-g [query]` or `-G [query]` allows you to filter the output.
121
124
 
122
125
  Workspace
@@ -145,13 +148,12 @@ Debugging
145
148
  info Start the debugger of debug.gem and run its `info` command.
146
149
 
147
150
  Misc
148
- edit Open a file with the editor command defined with `ENV["VISUAL"]` or `ENV["EDITOR"]`.
151
+ edit Open a file or source location.
149
152
  measure `measure` enables the mode to measure processing time. `measure :off` disables it.
150
153
 
151
154
  Context
152
- help [DEPRECATED] Enter the mode to look up RI documents.
153
155
  show_doc Enter the mode to look up RI documents.
154
- ls Show methods, constants, and variables. `-g [query]` or `-G [query]` allows you to filter out the output.
156
+ ls Show methods, constants, and variables.
155
157
  show_source Show the source code of a given method or constant.
156
158
  whereami Show the source code around binding.irb again.
157
159
 
@@ -227,7 +229,7 @@ end
227
229
 
228
230
  To learn about these features, please refer to `debug.gem`'s [commands list](https://github.com/ruby/debug#debug-command-on-the-debug-console).
229
231
 
230
- In the `irb:rdbg` session, the `show_cmds` command will also display all commands from `debug.gem`.
232
+ In the `irb:rdbg` session, the `help` command will also display all commands from `debug.gem`.
231
233
 
232
234
  ### Advantages Over `debug.gem`'s Console
233
235
 
@@ -384,7 +386,7 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/ruby/i
384
386
 
385
387
  ### Run integration tests
386
388
 
387
- If your changes affect component rendering, such as the autocompletion's dialog/dropdown, you may need to run IRB's integration tests, known as `yamatanarroroti`.
389
+ If your changes affect component rendering, such as the autocompletion's dialog/dropdown, you may need to run IRB's integration tests, known as `yamatanooroti`.
388
390
 
389
391
  Before running these tests, ensure that you have `libvterm` installed. If you're using Homebrew, you can install it by running:
390
392
 
data/Rakefile CHANGED
@@ -17,7 +17,7 @@ task :test_in_isolation do
17
17
  ENV["TEST"] = test_file
18
18
  begin
19
19
  Rake::Task["test"].execute
20
- rescue => e
20
+ rescue
21
21
  failed = true
22
22
  msg = "Test '#{test_file}' failed when being executed in isolation. Please make sure 'rake test TEST=#{test_file}' passes."
23
23
  separation_line = '=' * msg.length
data/lib/irb/cmd/nop.rb CHANGED
@@ -1,53 +1,4 @@
1
- # frozen_string_literal: false
2
- #
3
- # nop.rb -
4
- # by Keiju ISHITSUKA(keiju@ruby-lang.org)
5
- #
1
+ # frozen_string_literal: true
6
2
 
7
- module IRB
8
- # :stopdoc:
9
-
10
- module ExtendCommand
11
- class CommandArgumentError < StandardError; end
12
-
13
- class Nop
14
- class << self
15
- def category(category = nil)
16
- @category = category if category
17
- @category
18
- end
19
-
20
- def description(description = nil)
21
- @description = description if description
22
- @description
23
- end
24
-
25
- private
26
-
27
- def string_literal?(args)
28
- sexp = Ripper.sexp(args)
29
- sexp && sexp.size == 2 && sexp.last&.first&.first == :string_literal
30
- end
31
- end
32
-
33
- def self.execute(irb_context, *opts, **kwargs, &block)
34
- command = new(irb_context)
35
- command.execute(*opts, **kwargs, &block)
36
- rescue CommandArgumentError => e
37
- puts e.message
38
- end
39
-
40
- def initialize(irb_context)
41
- @irb_context = irb_context
42
- end
43
-
44
- attr_reader :irb_context
45
-
46
- def execute(*opts)
47
- #nop
48
- end
49
- end
50
- end
51
-
52
- # :startdoc:
53
- end
3
+ # This file is just a placeholder for backward-compatibility.
4
+ # Please require 'irb' and inheirt your command from `IRB::Command::Base` instead.
@@ -5,7 +5,7 @@ require_relative "debug"
5
5
  module IRB
6
6
  # :stopdoc:
7
7
 
8
- module ExtendCommand
8
+ module Command
9
9
  class Backtrace < DebugCommand
10
10
  def self.transform_args(args)
11
11
  args&.dump
@@ -0,0 +1,64 @@
1
+ # frozen_string_literal: true
2
+ #
3
+ # nop.rb -
4
+ # by Keiju ISHITSUKA(keiju@ruby-lang.org)
5
+ #
6
+
7
+ module IRB
8
+ # :stopdoc:
9
+
10
+ module Command
11
+ class CommandArgumentError < StandardError; end
12
+
13
+ class Base
14
+ class << self
15
+ def category(category = nil)
16
+ @category = category if category
17
+ @category
18
+ end
19
+
20
+ def description(description = nil)
21
+ @description = description if description
22
+ @description
23
+ end
24
+
25
+ def help_message(help_message = nil)
26
+ @help_message = help_message if help_message
27
+ @help_message
28
+ end
29
+
30
+ private
31
+
32
+ def string_literal?(args)
33
+ sexp = Ripper.sexp(args)
34
+ sexp && sexp.size == 2 && sexp.last&.first&.first == :string_literal
35
+ end
36
+
37
+ def highlight(text)
38
+ Color.colorize(text, [:BOLD, :BLUE])
39
+ end
40
+ end
41
+
42
+ def self.execute(irb_context, *opts, **kwargs, &block)
43
+ command = new(irb_context)
44
+ command.execute(*opts, **kwargs, &block)
45
+ rescue CommandArgumentError => e
46
+ puts e.message
47
+ end
48
+
49
+ def initialize(irb_context)
50
+ @irb_context = irb_context
51
+ end
52
+
53
+ attr_reader :irb_context
54
+
55
+ def execute(*opts)
56
+ #nop
57
+ end
58
+ end
59
+
60
+ Nop = Base
61
+ end
62
+
63
+ # :startdoc:
64
+ end
@@ -5,7 +5,7 @@ require_relative "debug"
5
5
  module IRB
6
6
  # :stopdoc:
7
7
 
8
- module ExtendCommand
8
+ module Command
9
9
  class Break < DebugCommand
10
10
  def self.transform_args(args)
11
11
  args&.dump
@@ -5,7 +5,7 @@ require_relative "debug"
5
5
  module IRB
6
6
  # :stopdoc:
7
7
 
8
- module ExtendCommand
8
+ module Command
9
9
  class Catch < DebugCommand
10
10
  def self.transform_args(args)
11
11
  args&.dump
@@ -1,18 +1,16 @@
1
- # frozen_string_literal: false
1
+ # frozen_string_literal: true
2
2
  #
3
3
  # change-ws.rb -
4
4
  # by Keiju ISHITSUKA(keiju@ruby-lang.org)
5
5
  #
6
-
7
- require_relative "nop"
8
6
  require_relative "../ext/change-ws"
9
7
 
10
8
  module IRB
11
9
  # :stopdoc:
12
10
 
13
- module ExtendCommand
11
+ module Command
14
12
 
15
- class CurrentWorkingWorkspace < Nop
13
+ class CurrentWorkingWorkspace < Base
16
14
  category "Workspace"
17
15
  description "Show the current workspace."
18
16
 
@@ -21,7 +19,7 @@ module IRB
21
19
  end
22
20
  end
23
21
 
24
- class ChangeWorkspace < Nop
22
+ class ChangeWorkspace < Base
25
23
  category "Workspace"
26
24
  description "Change the current workspace to an object."
27
25
 
@@ -5,7 +5,7 @@ require_relative "debug"
5
5
  module IRB
6
6
  # :stopdoc:
7
7
 
8
- module ExtendCommand
8
+ module Command
9
9
  class Continue < DebugCommand
10
10
  def execute(*args)
11
11
  super(do_cmds: ["continue", *args].join(" "))
@@ -1,18 +1,17 @@
1
- require_relative "nop"
2
1
  require_relative "../debug"
3
2
 
4
3
  module IRB
5
4
  # :stopdoc:
6
5
 
7
- module ExtendCommand
8
- class Debug < Nop
6
+ module Command
7
+ class Debug < Base
9
8
  category "Debugging"
10
9
  description "Start the debugger of debug.gem."
11
10
 
12
11
  BINDING_IRB_FRAME_REGEXPS = [
13
12
  '<internal:prelude>',
14
13
  binding.method(:irb).source_location.first,
15
- ].map { |file| /\A#{Regexp.escape(file)}:\d+:in `irb'\z/ }
14
+ ].map { |file| /\A#{Regexp.escape(file)}:\d+:in (`|'Binding#)irb'\z/ }
16
15
 
17
16
  def execute(pre_cmds: nil, do_cmds: nil)
18
17
  if irb_context.with_debugger
@@ -5,7 +5,7 @@ require_relative "debug"
5
5
  module IRB
6
6
  # :stopdoc:
7
7
 
8
- module ExtendCommand
8
+ module Command
9
9
  class Delete < DebugCommand
10
10
  def execute(*args)
11
11
  super(pre_cmds: ["delete", *args].join(" "))
@@ -0,0 +1,70 @@
1
+ require 'shellwords'
2
+
3
+ require_relative "../source_finder"
4
+
5
+ module IRB
6
+ # :stopdoc:
7
+
8
+ module Command
9
+ class Edit < Base
10
+ category "Misc"
11
+ description 'Open a file or source location.'
12
+ help_message <<~HELP_MESSAGE
13
+ Usage: edit [FILE or constant or method signature]
14
+
15
+ Open a file in the editor specified in #{highlight('ENV["VISUAL"]')} or #{highlight('ENV["EDITOR"]')}
16
+
17
+ - If no arguments are provided, IRB will attempt to open the file the current context was defined in.
18
+ - If FILE is provided, IRB will open the file.
19
+ - If a constant or method signature is provided, IRB will attempt to locate the source file and open it.
20
+
21
+ Examples:
22
+
23
+ edit
24
+ edit foo.rb
25
+ edit Foo
26
+ edit Foo#bar
27
+ HELP_MESSAGE
28
+
29
+ class << self
30
+ def transform_args(args)
31
+ # Return a string literal as is for backward compatibility
32
+ if args.nil? || args.empty? || string_literal?(args)
33
+ args
34
+ else # Otherwise, consider the input as a String for convenience
35
+ args.strip.dump
36
+ end
37
+ end
38
+ end
39
+
40
+ def execute(*args)
41
+ path = args.first
42
+
43
+ if path.nil?
44
+ path = @irb_context.irb_path
45
+ elsif !File.exist?(path)
46
+ source = SourceFinder.new(@irb_context).find_source(path)
47
+
48
+ if source&.file_exist? && !source.binary_file?
49
+ path = source.file
50
+ end
51
+ end
52
+
53
+ unless File.exist?(path)
54
+ puts "Can not find file: #{path}"
55
+ return
56
+ end
57
+
58
+ if editor = (ENV['VISUAL'] || ENV['EDITOR'])
59
+ puts "command: '#{editor}'"
60
+ puts " path: #{path}"
61
+ system(*Shellwords.split(editor), path)
62
+ else
63
+ puts "Can not find editor setting: ENV['VISUAL'] or ENV['EDITOR']"
64
+ end
65
+ end
66
+ end
67
+ end
68
+
69
+ # :startdoc:
70
+ end
@@ -1,12 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative "nop"
4
-
5
3
  module IRB
6
4
  # :stopdoc:
7
5
 
8
- module ExtendCommand
9
- class Exit < Nop
6
+ module Command
7
+ class Exit < Base
10
8
  category "IRB"
11
9
  description "Exit the current irb session."
12
10
 
@@ -5,7 +5,7 @@ require_relative "debug"
5
5
  module IRB
6
6
  # :stopdoc:
7
7
 
8
- module ExtendCommand
8
+ module Command
9
9
  class Finish < DebugCommand
10
10
  def execute(*args)
11
11
  super(do_cmds: ["finish", *args].join(" "))
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ module IRB
4
+ # :stopdoc:
5
+
6
+ module Command
7
+ class ForceExit < Base
8
+ category "IRB"
9
+ description "Exit the current process."
10
+
11
+ def execute(*)
12
+ throw :IRB_EXIT, true
13
+ rescue UncaughtThrowError
14
+ Kernel.exit!
15
+ end
16
+ end
17
+ end
18
+
19
+ # :startdoc:
20
+ end
@@ -0,0 +1,84 @@
1
+ # frozen_string_literal: true
2
+
3
+ module IRB
4
+ module Command
5
+ class Help < Base
6
+ category "Help"
7
+ description "List all available commands. Use `help <command>` to get information about a specific command."
8
+
9
+ class << self
10
+ def transform_args(args)
11
+ # Return a string literal as is for backward compatibility
12
+ if args.empty? || string_literal?(args)
13
+ args
14
+ else # Otherwise, consider the input as a String for convenience
15
+ args.strip.dump
16
+ end
17
+ end
18
+ end
19
+
20
+ def execute(command_name = nil)
21
+ content =
22
+ if command_name
23
+ if command_class = ExtendCommandBundle.load_command(command_name)
24
+ command_class.help_message || command_class.description
25
+ else
26
+ "Can't find command `#{command_name}`. Please check the command name and try again.\n\n"
27
+ end
28
+ else
29
+ help_message
30
+ end
31
+ Pager.page_content(content)
32
+ end
33
+
34
+ private
35
+
36
+ def help_message
37
+ commands_info = IRB::ExtendCommandBundle.all_commands_info
38
+ commands_grouped_by_categories = commands_info.group_by { |cmd| cmd[:category] }
39
+
40
+ user_aliases = irb_context.instance_variable_get(:@user_aliases)
41
+
42
+ commands_grouped_by_categories["Aliases"] = user_aliases.map do |alias_name, target|
43
+ { display_name: alias_name, description: "Alias for `#{target}`" }
44
+ end
45
+
46
+ if irb_context.with_debugger
47
+ # Remove the original "Debugging" category
48
+ commands_grouped_by_categories.delete("Debugging")
49
+ # Add an empty "Debugging (from debug.gem)" category at the end
50
+ commands_grouped_by_categories["Debugging (from debug.gem)"] = []
51
+ end
52
+
53
+ longest_cmd_name_length = commands_info.map { |c| c[:display_name].length }.max
54
+
55
+ output = StringIO.new
56
+
57
+ help_cmds = commands_grouped_by_categories.delete("Help")
58
+
59
+ add_category_to_output("Help", help_cmds, output, longest_cmd_name_length)
60
+
61
+ commands_grouped_by_categories.each do |category, cmds|
62
+ add_category_to_output(category, cmds, output, longest_cmd_name_length)
63
+ end
64
+
65
+ # Append the debugger help at the end
66
+ if irb_context.with_debugger
67
+ output.puts DEBUGGER__.help
68
+ end
69
+
70
+ output.string
71
+ end
72
+
73
+ def add_category_to_output(category, cmds, output, longest_cmd_name_length)
74
+ output.puts Color.colorize(category, [:BOLD])
75
+
76
+ cmds.each do |cmd|
77
+ output.puts " #{cmd[:display_name].to_s.ljust(longest_cmd_name_length)} #{cmd[:description]}"
78
+ end
79
+
80
+ output.puts
81
+ end
82
+ end
83
+ end
84
+ end
@@ -1,14 +1,14 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "stringio"
4
- require_relative "nop"
4
+
5
5
  require_relative "../pager"
6
6
 
7
7
  module IRB
8
8
  # :stopdoc:
9
9
 
10
- module ExtendCommand
11
- class History < Nop
10
+ module Command
11
+ class History < Base
12
12
  category "IRB"
13
13
  description "Shows the input history. `-g [query]` or `-G [query]` allows you to filter the output."
14
14
 
@@ -5,7 +5,7 @@ require_relative "debug"
5
5
  module IRB
6
6
  # :stopdoc:
7
7
 
8
- module ExtendCommand
8
+ module Command
9
9
  class Info < DebugCommand
10
10
  def self.transform_args(args)
11
11
  args&.dump
@@ -1,12 +1,10 @@
1
- # frozen_string_literal: false
2
-
3
- require_relative "nop"
1
+ # frozen_string_literal: true
4
2
 
5
3
  module IRB
6
4
  # :stopdoc:
7
5
 
8
- module ExtendCommand
9
- class IrbInfo < Nop
6
+ module Command
7
+ class IrbInfo < Base
10
8
  category "IRB"
11
9
  description "Show information about IRB."
12
10
 
@@ -15,7 +13,8 @@ module IRB
15
13
  str += "IRB version: #{IRB.version}\n"
16
14
  str += "InputMethod: #{IRB.CurrentContext.io.inspect}\n"
17
15
  str += "Completion: #{IRB.CurrentContext.io.respond_to?(:completion_info) ? IRB.CurrentContext.io.completion_info : 'off'}\n"
18
- str += ".irbrc path: #{IRB.rc_file}\n" if File.exist?(IRB.rc_file)
16
+ rc_files = IRB.rc_files.select { |rc| File.exist?(rc) }
17
+ str += ".irbrc paths: #{rc_files.join(", ")}\n" if rc_files.any?
19
18
  str += "RUBY_PLATFORM: #{RUBY_PLATFORM}\n"
20
19
  str += "LANG env: #{ENV["LANG"]}\n" if ENV["LANG"] && !ENV["LANG"].empty?
21
20
  str += "LC_ALL env: #{ENV["LC_ALL"]}\n" if ENV["LC_ALL"] && !ENV["LC_ALL"].empty?
@@ -1,17 +1,15 @@
1
- # frozen_string_literal: false
1
+ # frozen_string_literal: true
2
2
  #
3
3
  # load.rb -
4
4
  # by Keiju ISHITSUKA(keiju@ruby-lang.org)
5
5
  #
6
-
7
- require_relative "nop"
8
6
  require_relative "../ext/loader"
9
7
 
10
8
  module IRB
11
9
  # :stopdoc:
12
10
 
13
- module ExtendCommand
14
- class LoaderCommand < Nop
11
+ module Command
12
+ class LoaderCommand < Base
15
13
  include IrbLoader
16
14
 
17
15
  def raise_cmd_argument_error
@@ -2,17 +2,23 @@
2
2
 
3
3
  require "reline"
4
4
  require "stringio"
5
- require_relative "nop"
5
+
6
6
  require_relative "../pager"
7
7
  require_relative "../color"
8
8
 
9
9
  module IRB
10
10
  # :stopdoc:
11
11
 
12
- module ExtendCommand
13
- class Ls < Nop
12
+ module Command
13
+ class Ls < Base
14
14
  category "Context"
15
- description "Show methods, constants, and variables. `-g [query]` or `-G [query]` allows you to filter out the output."
15
+ description "Show methods, constants, and variables."
16
+
17
+ help_message <<~HELP_MESSAGE
18
+ Usage: ls [obj] [-g [query]]
19
+
20
+ -g [query] Filter the output with a query.
21
+ HELP_MESSAGE
16
22
 
17
23
  def self.transform_args(args)
18
24
  if match = args&.match(/\A(?<args>.+\s|)(-g|-G)\s+(?<grep>[^\s]+)\s*\n\z/)
@@ -1,10 +1,8 @@
1
- require_relative "nop"
2
-
3
1
  module IRB
4
2
  # :stopdoc:
5
3
 
6
- module ExtendCommand
7
- class Measure < Nop
4
+ module Command
5
+ class Measure < Base
8
6
  category "Misc"
9
7
  description "`measure` enables the mode to measure processing time. `measure :off` disables it."
10
8
 
@@ -5,7 +5,7 @@ require_relative "debug"
5
5
  module IRB
6
6
  # :stopdoc:
7
7
 
8
- module ExtendCommand
8
+ module Command
9
9
  class Next < DebugCommand
10
10
  def execute(*args)
11
11
  super(do_cmds: ["next", *args].join(" "))