Class: Looped::Tools::SearchCode

Inherits:
DSPy::Tools::Base
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/looped/tools/search_code.rb

Instance Method Summary collapse

Instance Method Details

#call(pattern:, path: '.', file_type: nil) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/looped/tools/search_code.rb', line 15

def call(pattern:, path: '.', file_type: nil)
  cmd = build_command(pattern, path, file_type)
  output, status = Open3.capture2e(*cmd)

  if status.success?
    output.empty? ? "No matches found for: #{pattern}" : output
  else
    "No matches found for: #{pattern}"
  end
rescue StandardError => e
  "Error: #{e.message}"
end