Added uberjar
This commit is contained in:
parent
76ed6b6e7b
commit
de5239bd7a
6 changed files with 44 additions and 26 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -13,4 +13,5 @@ public/js/
|
||||||
|
|
||||||
*.iml
|
*.iml
|
||||||
.idea/
|
.idea/
|
||||||
|
.lein-repl-history
|
||||||
|
|
||||||
|
|
|
@ -17,9 +17,7 @@
|
||||||
:profiles {:test {:test-paths ["src/test/cljc"]
|
:profiles {:test {:test-paths ["src/test/cljc"]
|
||||||
:resource-paths ["src/test/resources"]
|
:resource-paths ["src/test/resources"]
|
||||||
:dependencies [[dda/data-test "0.1.1"]]}
|
:dependencies [[dda/data-test "0.1.1"]]}
|
||||||
:uberjar {:source-paths ["src/main/clj"]
|
:uberjar {:aot :all
|
||||||
:resource-paths ["src/main/resources"]
|
|
||||||
:aot :all
|
|
||||||
:main dda.k8s-mastodon-bot.uberjar
|
:main dda.k8s-mastodon-bot.uberjar
|
||||||
:uberjar-name "k8s-mastodon-bot-standalone.jar"
|
:uberjar-name "k8s-mastodon-bot-standalone.jar"
|
||||||
:dependencies [[org.clojure/tools.cli "1.0.194"]
|
:dependencies [[org.clojure/tools.cli "1.0.194"]
|
||||||
|
|
41
src/main/clj/dda/k8s_mastodon_bot/uberjar.clj
Normal file
41
src/main/clj/dda/k8s_mastodon_bot/uberjar.clj
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
(ns dda.k8s-mastodon-bot.uberjar
|
||||||
|
(:gen-class)
|
||||||
|
(:require
|
||||||
|
[clojure.spec.alpha :as s]
|
||||||
|
[dda.k8s-mastodon-bot.core :as core]))
|
||||||
|
|
||||||
|
|
||||||
|
(def usage
|
||||||
|
"usage:
|
||||||
|
|
||||||
|
k8s-mastodon-bot '{your configuraton}' '{your authorization}'")
|
||||||
|
|
||||||
|
; Checks if a string validates a given spec after the string is transformed to Clojure data structure by clojure.edn/read-string.
|
||||||
|
(defn spec-string? [spec]
|
||||||
|
(fn [str]
|
||||||
|
(s/and
|
||||||
|
(string? str)
|
||||||
|
(s/valid? spec (clojure.edn/read-string str)))))
|
||||||
|
|
||||||
|
(s/def ::config-map-str (spec-string? ::core/config))
|
||||||
|
(s/def ::auth-map-str (spec-string? ::core/auth))
|
||||||
|
(s/def ::cmd-args (s/cat :options ::core/options
|
||||||
|
:config ::config-map-str
|
||||||
|
:auth ::config-map-str))
|
||||||
|
|
||||||
|
(defn invalid-args-msg [spec args]
|
||||||
|
(do (s/explain spec args)
|
||||||
|
(println (str "Bad commandline arguments\n" usage))))
|
||||||
|
|
||||||
|
(defn -main [& cmd-args]
|
||||||
|
(let [parsed-args-cmd (s/conform ::cmd-args cmd-args)]
|
||||||
|
(if (= ::s/invalid parsed-args-cmd)
|
||||||
|
(invalid-args-msg ::cmd-args cmd-args)
|
||||||
|
(let [{:keys [options config auth]} parsed-args-cmd
|
||||||
|
config-map (clojure.edn/read-string config)
|
||||||
|
auth-map (clojure.edn/read-string auth)]
|
||||||
|
(cond
|
||||||
|
(some #(= "-h" %) options)
|
||||||
|
(println usage)
|
||||||
|
:default
|
||||||
|
(println (core/generate config-map auth-map)))))))
|
|
@ -1,22 +0,0 @@
|
||||||
(ns dda.k8s-mastodon-bot.uberjar
|
|
||||||
(:require
|
|
||||||
[clojure.spec.alpha :as s]
|
|
||||||
[dda.k8s-mastodon-bot.core :as core]))
|
|
||||||
|
|
||||||
|
|
||||||
(def usage
|
|
||||||
"usage:
|
|
||||||
|
|
||||||
k8s-mastodon-bot {your configuraton} {your authorization}")
|
|
||||||
|
|
||||||
(defn main [& args]
|
|
||||||
(let [parsed-args (s/conform ::core/args args)]
|
|
||||||
(if (= ::s/invalid parsed-args)
|
|
||||||
(do (s/explain ::core/args args)
|
|
||||||
(print (str "Bad commandline arguments\n" usage)))
|
|
||||||
(let [{:keys [options config auth]} parsed-args]
|
|
||||||
(cond
|
|
||||||
(some #(= "-h" %) options)
|
|
||||||
(print usage)
|
|
||||||
:default
|
|
||||||
(core/generate config auth))))))
|
|
|
@ -6,7 +6,7 @@
|
||||||
[dda.k8s-mastodon-bot.yaml :as yaml]
|
[dda.k8s-mastodon-bot.yaml :as yaml]
|
||||||
))
|
))
|
||||||
|
|
||||||
(set! s/*explain-out* expound/printer)
|
;(set! s/*explain-out* expound/printer)
|
||||||
|
|
||||||
(s/def ::options (s/* #{"-h"}))
|
(s/def ::options (s/* #{"-h"}))
|
||||||
(s/def ::config map?)
|
(s/def ::config map?)
|
||||||
|
|
Loading…
Reference in a new issue