summaryrefslogtreecommitdiff
path: root/lib/irb/context.rb
diff options
context:
space:
mode:
authorTakashi Kokubun <[email protected]>2022-11-07 09:29:24 -0800
committergit <[email protected]>2022-11-07 17:29:28 +0000
commit9001e53e68d282493f513ed67824e4014fd01d57 (patch)
tree1b8070f10aa422b2d6510c56f93e924c0bb4abbf /lib/irb/context.rb
parent7442cb461b32de2eec3b37f52d80752d30627de0 (diff)
[ruby/irb] Support non-string input in show_source
(https://github.com/ruby/irb/pull/430) * Support non-string input in show_source * Test show_source as a method
Diffstat (limited to 'lib/irb/context.rb')
-rw-r--r--lib/irb/context.rb9
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/irb/context.rb b/lib/irb/context.rb
index d1ae2cb605..72c74f081d 100644
--- a/lib/irb/context.rb
+++ b/lib/irb/context.rb
@@ -484,9 +484,16 @@ module IRB
end
# Transform a non-identifier alias (ex: @, $)
- command = line.split(/\s/, 2).first
+ command, args = line.split(/\s/, 2)
if original = symbol_alias(command)
line = line.gsub(/\A#{Regexp.escape(command)}/, original.to_s)
+ command = original
+ end
+
+ # Hook command-specific transformation
+ command_class = ExtendCommandBundle.load_command(command)
+ if command_class&.respond_to?(:transform_args)
+ line = "#{command} #{command_class.transform_args(args)}"
end
set_last_value(@workspace.evaluate(self, line, irb_path, line_no))