    lucene indexes for your maven repositories.
    Options:
      --page   -- The page number to fetch (each page is 10 results long).
-     --repos  -- ids of repositories to search delimited by commas."
-  {[page] :page repos :repos search :search}
+     --repos  -- ids of repositories to search delimited by commas.
+     --update -- Updates indices for repos you specify."
+  {[page] :page repos :repos search :search update :update}
   (let [page (if page (Integer. page) 1)]
     (binding [sherlock/*page-size* 10]
       (doseq [[id url] (select-repos repos)]
         (download-index id url)
-        (update-repo id url)
+        (when update (update-repo id url))
+        (needs-updating? id url)
         (print-results
          id page
          (sherlock/get-page page (sherlock/search url (join " " search) page)))))))

   and return the latest version. You can pass --repos which is expected to be a
   comma delimited list of repository names. If it is not passed, all repositories
   will be searched."
  {[term] :latest-version, repos :repos}
  (let [repos (select-repos repos)
        [group-id artifact-id] (.split term "/")
        query (str "g:" group-id " AND a:" (or artifact-id group-id))]
    (doseq [[id url] repos]
      (download-index id url)
      (update-repo id url))
    (let [result (first (sort-by :version (comp unchecked-negate compare)
                                 (filter (comp #{term} identifier)
                                         (mapcat #(sherlock/search % query 10 Integer/MAX_VALUE)

(ns cake.tasks.search
  (:use cake
        cake.core
        [bake.core :only [log]]
        [clojure.string :only [join]]
        [clojure.java.io :only [file copy reader]])
