diff options
Diffstat (limited to 'lib/irb/extend-command.rb')
-rw-r--r-- | lib/irb/extend-command.rb | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/irb/extend-command.rb b/lib/irb/extend-command.rb index 508721c11d..de797ab78b 100644 --- a/lib/irb/extend-command.rb +++ b/lib/irb/extend-command.rb @@ -126,9 +126,14 @@ module IRB eval %[ def #{cmd_name}(*opts, &b) require "#{load_file}" + arity = ExtendCommand::#{cmd_class}.instance_method(:execute).arity + args = (1..arity.abs).map {|i| "arg" + i.to_s } + args << "*opts" if arity < 0 + args << "&block" + args = args.join(", ") eval %[ - def #{cmd_name}(*opts, &b) - ExtendCommand::#{cmd_class}.execute(irb_context, *opts, &b) + def #{cmd_name}(\#{args}) + ExtendCommand::#{cmd_class}.execute(irb_context, \#{args}) end ] send :#{cmd_name}, *opts, &b |