Updated uberjar spec
This commit is contained in:
parent
293511cfc9
commit
a437a8bc5f
1 changed files with 11 additions and 10 deletions
|
@ -2,24 +2,25 @@
|
||||||
(:gen-class)
|
(:gen-class)
|
||||||
(:require
|
(:require
|
||||||
[clojure.spec.alpha :as s]
|
[clojure.spec.alpha :as s]
|
||||||
|
[clojure.string :as cs]
|
||||||
[expound.alpha :as expound]
|
[expound.alpha :as expound]
|
||||||
[clojure.java.io :as io]
|
[clojure.java.io :as io]
|
||||||
[dda.k8s-mastodon-bot.core :as core]))
|
[dda.k8s-mastodon-bot.core :as core]))
|
||||||
|
|
||||||
(alter-var-root #'s/*explain-out* (constantly expound/printer))
|
(alter-var-root #'s/*explain-out* (constantly expound/printer))
|
||||||
|
|
||||||
(s/def ::options (s/* #{"-h"}))
|
|
||||||
(s/def ::args (s/cat :options ::options))
|
|
||||||
|
|
||||||
(def usage
|
(def usage
|
||||||
"usage:
|
"usage:
|
||||||
|
|
||||||
k8s-mastodon-bot {your configuraton file} {your authorization file}")
|
k8s-mastodon-bot {your configuraton file} {your authorization file}")
|
||||||
|
|
||||||
(s/def ::filename string?)
|
(s/def ::options (s/* #{"-h"}))
|
||||||
|
(s/def ::filename (s/and string?
|
||||||
|
#(not (cs/starts-with? % "-"))))
|
||||||
(s/def ::cmd-args (s/cat :options ::options
|
(s/def ::cmd-args (s/cat :options ::options
|
||||||
:config ::filename
|
:args (s/?
|
||||||
:auth ::filename))
|
(s/cat :config ::filename
|
||||||
|
:auth ::filename))))
|
||||||
|
|
||||||
(defn invalid-args-msg [spec args]
|
(defn invalid-args-msg [spec args]
|
||||||
(do (s/explain spec args)
|
(do (s/explain spec args)
|
||||||
|
@ -29,11 +30,11 @@
|
||||||
(let [parsed-args-cmd (s/conform ::cmd-args cmd-args)]
|
(let [parsed-args-cmd (s/conform ::cmd-args cmd-args)]
|
||||||
(if (= ::s/invalid parsed-args-cmd)
|
(if (= ::s/invalid parsed-args-cmd)
|
||||||
(invalid-args-msg ::cmd-args cmd-args)
|
(invalid-args-msg ::cmd-args cmd-args)
|
||||||
(let [{:keys [options config auth]} parsed-args-cmd
|
(let [{:keys [options args]} parsed-args-cmd
|
||||||
config-map (slurp config)
|
config-location (:config args)
|
||||||
auth-map (slurp auth)]
|
auth-location (:auth args)]
|
||||||
(cond
|
(cond
|
||||||
(some #(= "-h" %) options)
|
(some #(= "-h" %) options)
|
||||||
(println usage)
|
(println usage)
|
||||||
:default
|
:default
|
||||||
(println (core/generate config-map auth-map)))))))
|
(println (core/generate (slurp config-location) (slurp auth-location))))))))
|
||||||
|
|
Loading…
Reference in a new issue