lib/snibbets.rb in snibbets-2.0.33 vs lib/snibbets.rb in snibbets-2.0.34
- old
+ new
@@ -59,13 +59,11 @@
when 2
rg = TTY::Which.which('rg')
ag = TTY::Which.which('ag')
ack = TTY::Which.which('ack')
grep = TTY::Which.which('grep')
- if Snibbets.options[:name_only]
- nil
- elsif !rg.empty?
+ if !rg.empty?
%(#{rg} -li --color=never --glob='*.#{ext}' '#{@query.rx}' "#{folder}")
elsif !ag.empty?
%(#{ag} -li --nocolor -G '.*.#{ext}' '#{@query.rx}' "#{folder}")
elsif !ack.empty?
%(#{ack} -li --nocolor --markdown '#{@query.rx}' "#{folder}")
@@ -82,12 +80,17 @@
name_only = Snibbets.options[:name_only] ? '-name ' : ''
%(mdfind -onlyin #{folder} #{name_only}'#{@query} filename:.#{ext}' 2>/dev/null)
end
end
- if try == 2 && cmd.nil?
- puts "{br}No search method available on this system. Please install ripgrep, silver surfer, ack, or grep.".x
- Process.exit 1
+ if try == 2
+ if Snibbets.options[:name_only]
+ puts '{br}No name matches found'.x
+ Process.exit 1
+ elsif cmd.nil?
+ puts '{br}No search method available on this system. Please install ripgrep, silver surfer, ack, or grep.'.x
+ Process.exit 1
+ end
end
res = cmd.nil? ? '' : `#{cmd}`.strip
matches = []