 (ns org.quattor.pan.pan-annotations
   (:gen-class)
-  (:require [clojure.tools.cli :refer :all]
-            [clojure.string :as str])
+  (:require [clojure.tools.cli :refer [parse-opts]]
+            [clojure.string :as string])
   (:import (java.io File)
            (org.quattor.pan CompilerOptions CompilerResults)))
 

        pan-sources (map #(File. ^String %) files)]
    (org.quattor.pan.Compiler/run compiler-options nil pan-sources)))

(defn -main [& args]
  (let [[options files banner]
        (cli args
             ["--base-dir" "base directory for templates" 
              :default (current-directory) :parse-fn parse-directory]
             ["--output-dir" "output directory" 
              :default (current-directory) :parse-fn parse-directory]
             ["--java-opts" "options for JVM"]
             ["-v" "--verbose" "show statistics and progress" :default false :flag true]
             ["-h" "--help" "print command help" :default false :flag true])]
    (when (:help options)
      (println banner)
      (System/exit 0))
    (let [^CompilerResults results (generate-annotations options files)]
      (if-let [errors (.formatErrors results)]
        (println errors)
        "")
      (println (.formatStats results)))))

    (list (create-absolute-file ""))))

(defn parse-directory [dir]
  (if (string/blank? dir)
    (current-directory)
    (create-absolute-file dir)))

