         nnproj (with-meta nproj nmeta)]
     nnproj))
 
-(defn ver-parse
+(defn ^:info-subtask ver-parse
   "Parses jar-path-like-string or artifact-version-string to find ctime and sha.
    Can handle cases in the range of:
      1.2.3-20120219223112-abc123f

          input-str
          replacement-map))

(defn freshen [project & args]
  (p-repos (fn [p] (fetch-all [p]) (tag-repo-projects p)))
  (let [prj-file-name (str (:root project) "/project.clj")
        old-deps (:dependencies project)


;; === lein entrypoint ===

(defn wrap
  "Execute any lein task, but using git info as this project's version qualifier.

   Usage: lein voom wrap [<flags>] <lein task name> <lein task args>

   Flags:
     :insanely-allow-dirty-working-copy - by default voom sanely
         refuses to generate a voom-version from a dirty working copy
     :long-sha - uses a full length sha instead of the default
         short form

   Example: lein voom wrap install"
  [project & args]
  (let [[kw-like more-args] (split-with #(re-find #"^:" %) args)
        kargset (set (map edn/read-string kw-like))
        new-project (update-proj-version project (:long-sha kargset))]
    ;; TODO throw exception if upstream doesn't contain this commit :no-upstream
    ;;    :no-upstream - by default voom wants to see the current
    ;;      version reachable via an upstream repo
    (if (and (dirty-wc? (:root new-project))
             (not (:insanely-allow-dirty-working-copy kargset)))
      (lmain/abort "Refusing to continue with dirty working copy. (Hint: Run 'git status')")
      (lmain/resolve-and-apply new-project more-args))))

(defn install
  "Same as 'lein voom wrap install': install a voom-versioned artifact of this project.

  Example: lein voom install"
  [project & args]
  (apply wrap project "install" args))

(defn deploy
  "Same as 'lein voom wrap deploy': deploy a voom-versioned artifact of this project.

  Example: lein voom deploy clojars"
  [project & args]
  (apply wrap project "deploy" args))

(defn retag-all-repos
  "Clear and recreate all voom index tags in $VOOM_REPOS.

  You shouldn't need to use this usually because the index tags are
  automatically added incrementally and re-generated when tag schemas
  change.

  Example: lein voom retag-all-repos"
  [_]
  (time (p-repos (fn [p] (clear-voom-tags p) (tag-repo-projects p)))))

(def subtasks [#'build-deps #'deploy #'find-box #'freshen #'install
               #'retag-all-repos #'ver-parse #'wrap])

(def internal-subtasks [#'box #'box-new #'box-init #'box-add #'box-remove])

(defn ^:no-project-needed ^{:subtasks subtasks} voom
  "Generate and use artifacts versioned with git commit and commit time.

  There are several subtasks, as well as the 'box' script which has
  several commands of its own, built using this plugin."
  [project subtask-name & args]

  (let [subtask-var (resolve (symbol "leiningen.voom"
                                     (s/replace subtask-name #"^:" "")))]
    (if-let [subtask (some #{subtask-var} (concat subtasks internal-subtasks))]
      (if (:info-subtask (meta subtask))
        (prn (apply subtask args))
        (apply subtask project args))
      (println "No voom subtask found" (prn-str subtask-name)
               " Try: lein help voom"))))
