13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
# File 'lib/ripgrep/client.rb', line 13
def exec(*args, opts)
unless opts.is_a? Hash
args << opts
opts = {}
end
verbose = opts[:verbose].nil? ? @verbose : !!opts[:verbose]
cli_options = opts[:options]&.map do |key, val|
next unless val
val = '' if val.is_a? TrueClass
val = val.join if val.is_a? Array
key = key.to_s.tr('_', '-')
"--#{key} #{val}".strip
end&.compact || []
puts "cli_options: #{cli_options}" if verbose
cli_arguments = cli_options + args
cli_arguments << (opts[:path] || '.')
puts "cli_arguments: #{cli_arguments}" if verbose
Core.exec(*cli_arguments, verbose: verbose)
end
|