class Findex::Cli
Constants
- USAGE
Public Class Methods
new(args)
click to toggle source
# File lib/findex/cli.rb, line 8 def initialize(args) query_separator_index = args.find_index('--') || -1 action = args[0] path = query_separator_index != 1 ? args[1] : nil case action when 'index' then index(path || '.') when 'search' abort(USAGE) if query_separator_index == -1 search(path, args[query_separator_index..-1]) else abort("Unsupported action '#{action}'\n#{USAGE}") end end
Public Instance Methods
index(path)
click to toggle source
# File lib/findex/cli.rb, line 22 def index(path) Indexer.new(path || '.').start end
search(path, query_terms)
click to toggle source
# File lib/findex/cli.rb, line 26 def search(path, query_terms) Search.new(path || '.').query(query_terms).each do |document| puts document.full_path end end