diff options
author | Takashi Kokubun <takashikkbn@gmail.com> | 2021-03-18 00:28:04 -0700 |
---|---|---|
committer | git <svn-admin@ruby-lang.org> | 2021-03-21 12:59:51 +0900 |
commit | 5f72962a0955d62dfbac2f7553b725b9d1e9e60d (patch) | |
tree | d73f865d0ec71e2038463e4e6d19e814f8789f22 /lib/irb/extend-command.rb | |
parent | d36ac283d188ba6d923c905a85341761fa1305c3 (diff) |
[ruby/irb] Implement ls command
https://github.com/ruby/irb/commit/19b6c20604
Diffstat (limited to 'lib/irb/extend-command.rb')
-rw-r--r-- | lib/irb/extend-command.rb | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/lib/irb/extend-command.rb b/lib/irb/extend-command.rb index af076a6154..e7b046ad4e 100644 --- a/lib/irb/extend-command.rb +++ b/lib/irb/extend-command.rb @@ -126,6 +126,11 @@ module IRB # :nodoc: ], [ + :irb_ls, :Ls, "irb/cmd/ls", + [:ls, NO_OVERRIDE], + ], + + [ :irb_measure, :Measure, "irb/cmd/measure", [:measure, NO_OVERRIDE], ], @@ -169,12 +174,13 @@ module IRB # :nodoc: end if load_file + kwargs = ", **kwargs" if RUBY_ENGINE == "ruby" && RUBY_VERSION >= "2.7.0" line = __LINE__; eval %[ - def #{cmd_name}(*opts, &b) + def #{cmd_name}(*opts#{kwargs}, &b) require "#{load_file}" arity = ExtendCommand::#{cmd_class}.instance_method(:execute).arity args = (1..(arity < 0 ? ~arity : arity)).map {|i| "arg" + i.to_s } - args << "*opts" if arity < 0 + args << "*opts#{kwargs}" if arity < 0 args << "&block" args = args.join(", ") line = __LINE__; eval %[ @@ -185,7 +191,7 @@ module IRB # :nodoc: end end ], nil, __FILE__, line - __send__ :#{cmd_name}_, *opts, &b + __send__ :#{cmd_name}_, *opts#{kwargs}, &b end ], nil, __FILE__, line else |