Add version command line arg

Requires "project.clj" to be added in resource-path
This commit is contained in:
bom 2024-06-28 14:18:15 +02:00 committed by bom
parent 220aef9d5c
commit 4cbaac8d25
2 changed files with 6 additions and 2 deletions

View file

@ -12,7 +12,8 @@
:target-path "target/%s/"
:source-paths ["src/main/cljc"
"src/main/clj"]
:resource-paths ["src/main/resources"]
:resource-paths ["src/main/resources"
"project.clj"]
:repositories [["snapshots" :clojars]
["releases" :clojars]]
:deploy-repositories [["snapshots" {:sign-releases false :url "https://clojars.org/repo"}]

View file

@ -4,6 +4,7 @@
[clojure.spec.alpha :as s]
[clojure.string :as cs]
[clojure.tools.reader.edn :as edn]
[clojure.java.io :as io]
[dda.c4k-common.yaml :as yaml]
[dda.c4k-common.common :as cm]
[dda.c4k-common.core :as core]
@ -15,7 +16,7 @@
" name " {your configuraton file} {your authorization file}"))
(s/def ::options (s/* #{"-h"}))
(s/def ::options (s/* #{"-h" "-v" "--version"}))
(s/def ::filename (s/and string?
#(not (cs/starts-with? % "-"))))
(s/def ::cmd-args (s/cat :options ::options
@ -37,6 +38,8 @@
(cond
(some #(= "-h" %) options)
(println (usage name))
(some #(or (= "-v" %) (= "--version" %)) options)
(println (some-> (io/resource "project.clj") slurp edn/read-string (nth 2)))
:else
(let [config-str (slurp config)
auth-str (slurp auth)