summaryrefslogtreecommitdiff
path: root/lib/irb
diff options
context:
space:
mode:
authorTakashi Kokubun <takashikkbn@gmail.com>2022-11-10 14:55:11 -0800
committergit <svn-admin@ruby-lang.org>2022-11-10 22:55:15 +0000
commit8fa83fa0b2031ad17f01b5a12b39599398dc6da6 (patch)
tree99b01439ea80f7b3c3a2d2425def6d53e8bdb747 /lib/irb
parentd5513da01d24fbc4de71975b6a49f0ba3b3be401 (diff)
[ruby/irb] Transform ls's --grep/-G option to keyword args
(https://github.com/ruby/irb/pull/437) * Transform ls's --grep/-G option to keyword args * Make --grep less flexible * Support -g instead of --grep * Suppress warnings from symbol aliases
Diffstat (limited to 'lib/irb')
-rw-r--r--lib/irb/cmd/ls.rb9
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/irb/cmd/ls.rb b/lib/irb/cmd/ls.rb
index f4a7348bd1..77cf071783 100644
--- a/lib/irb/cmd/ls.rb
+++ b/lib/irb/cmd/ls.rb
@@ -9,6 +9,15 @@ module IRB
module ExtendCommand
class Ls < Nop
+ def self.transform_args(args)
+ if match = args&.match(/\A(?<args>.+\s|)(-g|-G)\s+(?<grep>[^\s]+)\s*\n\z/)
+ args = match[:args]
+ "#{args}#{',' unless args.chomp.empty?} grep: /#{match[:grep]}/"
+ else
+ args
+ end
+ end
+
def execute(*arg, grep: nil)
o = Output.new(grep: grep)