diff --git a/deps.edn b/deps.edn index 93d432c..857e9de 100644 --- a/deps.edn +++ b/deps.edn @@ -1,6 +1,6 @@ {:paths ["profiles" "src"] :deps {nl.surf/apie {:git/url "https://github.com/SURFnet/apie.git" - :git/sha "b20c848b9898df038ebd582a913c7feac03ac899"}} + :git/sha "2d2cea531b3d29eb2ea4f4df46feb0f8ff5fb921"}} :aliases {:test {:extra-deps {lambdaisland/kaocha {:mvn/version "RELEASE"}} :main-opts ["-m" "kaocha.runner"]} :clj-kondo {:replace-deps {clj-kondo/clj-kondo {:mvn/version "RELEASE"}} diff --git a/src/nl/surf/eduhub_validator/main.clj b/src/nl/surf/eduhub_validator/main.clj index 32e3824..8783311 100644 --- a/src/nl/surf/eduhub_validator/main.clj +++ b/src/nl/surf/eduhub_validator/main.clj @@ -1,5 +1,6 @@ (ns nl.surf.eduhub-validator.main - (:require [clojure.java.io :as io] + (:require [babashka.json :as json] + [clojure.java.io :as io] [clojure.string :as string] [clojure.tools.cli :refer [parse-opts]] [nl.jomco.apie.main :as apie])) @@ -21,18 +22,37 @@ option)) apie/cli-options)) -(defn version - "Return app version" +(defn app-version + "Return version of app." [] (when-let [r (io/resource "nl/surf/eduhub_validator/version.txt")] (string/trim (slurp r)))) +(defn spec-version + "Return version of openapi spec for built-in profile." + [profile] + (-> profile + apie/file-or-resource + apie/read-edn + :openapi-spec + apie/file-or-resource + apie/read-json + (get-in ["info" "version"]))) + +(defn versions + "Return version of app and included openapi specs." + [] + (str "eduhub-validator " (app-version) "\n" + "included profiles:\n" + (string/join "\n" (map (fn [p] + (str " - " p " " (spec-version p))) + included-profiles)))) (defn -main [& args] (let [{:keys [errors summary options]} (parse-opts args cli-options)] (when (:print-version? options) - (println (version)) + (println (versions)) (System/exit 0)) (when (seq errors) (run! println errors)