    "clean",   ["Clean the chaincode project",          cleancmd/run]
    "package", ["Package the chaincode for deployment", packagecmd/run]})
 
+(defn version [] (str "obcc version: v" util/app-version))
+
 (defn usage [options-summary]
-  (->> (flatten [(str "obcc version: v" util/app-version)
+  (->> (flatten [(version)
                  ""
                  "Usage: obcc [options] action"
                  ""

(def cli-options
  ;; An option with a required argument
  [["-p" "--path PATH" "path to chaincode project" :default "./"]
   ["-h" "--help"]])

(defn exit [status msg & rest]


(defn -main [& args]
  (let [ {:keys [options arguments errors summary]} (parse-opts args cli-options) ]
    (cond

      (:help options)
      (exit 0 (usage summary))

      (:version options)
      (exit 0 (version))

      (= (count arguments) 0)
      (exit 0 (usage summary))

      (not= errors nil)
      (exit -1 "Error: " (string/join errors))

      (not= (count arguments) 1)
      (exit -1 "Error: bad argument count")

      :else
      (let [path (:path options)
            file (io/file path util/configname)]
        (do
          (cond (not (.isFile file))
                (exit -1 "Configuration not found at " path)
                :else
                (let [config (config/parser file)]
                  (if-let [[_ func] (subcommands (first arguments))]
                    (do
                      (func path config)
                      (System/exit 0))
                    (exit 1 (usage summary))))))))))
