Class: Taggata::Cli::SearchCommand

Inherits:
Clamp::Command
  • Object
show all
Defined in:
lib/taggata/cli/search.rb

Instance Method Summary collapse

Instance Method Details

#executeObject



9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/taggata/cli/search.rb', line 9

def execute
  results = ::Taggata::Parser::Query.new(@db).parse(query)
  if count?
    puts results.count
  else
    if results.empty?
      puts "No results matching the query."
    else
      method = names? ? :name : :path
      results.each { |file| puts file.send(method) }
    end
  end
end