using spec & fixing expound
This commit is contained in:
parent
9138ba5764
commit
4664f6b5d3
4 changed files with 25 additions and 14 deletions
7
.gitignore
vendored
7
.gitignore
vendored
|
@ -1,17 +1,22 @@
|
||||||
|
# pybuilder
|
||||||
.pybuilder/
|
.pybuilder/
|
||||||
__pycache__/
|
__pycache__/
|
||||||
|
|
||||||
|
# lein
|
||||||
target/
|
target/
|
||||||
|
.lein-repl-history
|
||||||
|
.lein-failures
|
||||||
|
|
||||||
|
# cljs
|
||||||
.shadow-cljs
|
.shadow-cljs
|
||||||
.nrepl-*
|
.nrepl-*
|
||||||
package-lock.json
|
package-lock.json
|
||||||
node_modules/
|
node_modules/
|
||||||
public/js/
|
public/js/
|
||||||
|
|
||||||
|
# ide
|
||||||
.calva
|
.calva
|
||||||
|
|
||||||
*.iml
|
*.iml
|
||||||
.idea/
|
.idea/
|
||||||
.lein-repl-history
|
|
||||||
|
|
||||||
|
|
|
@ -2,9 +2,14 @@
|
||||||
(:gen-class)
|
(:gen-class)
|
||||||
(:require
|
(:require
|
||||||
[clojure.spec.alpha :as s]
|
[clojure.spec.alpha :as s]
|
||||||
|
[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))
|
||||||
|
|
||||||
|
(s/def ::options (s/* #{"-h"}))
|
||||||
|
(s/def ::args (s/cat :options ::options))
|
||||||
|
|
||||||
(def usage
|
(def usage
|
||||||
"usage:
|
"usage:
|
||||||
|
|
|
@ -1,20 +1,11 @@
|
||||||
(ns dda.k8s-mastodon-bot.core
|
(ns dda.k8s-mastodon-bot.core
|
||||||
(:require
|
(:require
|
||||||
[clojure.spec.alpha :as s]
|
|
||||||
[clojure.string :as cs]
|
[clojure.string :as cs]
|
||||||
[expound.alpha :as expound]
|
[orchestra.core :refer-macros [defn-spec]]
|
||||||
|
[mastodon-bot.core-domain :as cd]
|
||||||
[dda.k8s-mastodon-bot.yaml :as yaml]
|
[dda.k8s-mastodon-bot.yaml :as yaml]
|
||||||
))
|
))
|
||||||
|
|
||||||
(alter-var-root #'s/*explain-out* (constantly expound/printer))
|
|
||||||
|
|
||||||
(s/def ::options (s/* #{"-h"}))
|
|
||||||
(s/def ::config map?)
|
|
||||||
(s/def ::auth map?)
|
|
||||||
(s/def ::args (s/cat :options ::options
|
|
||||||
:config ::config
|
|
||||||
:auth ::auth))
|
|
||||||
|
|
||||||
(defn generate-config [my-config my-auth]
|
(defn generate-config [my-config my-auth]
|
||||||
(->
|
(->
|
||||||
(yaml/from-string (yaml/load-resource "config.yaml"))
|
(yaml/from-string (yaml/load-resource "config.yaml"))
|
||||||
|
@ -26,7 +17,9 @@
|
||||||
(->
|
(->
|
||||||
(yaml/from-string (yaml/load-resource "deployment.yaml"))))
|
(yaml/from-string (yaml/load-resource "deployment.yaml"))))
|
||||||
|
|
||||||
(defn generate [my-config my-auth]
|
(defn-spec generate any?
|
||||||
|
[my-config cd/config?
|
||||||
|
my-auth cd/auth?]
|
||||||
(cs/join "\n"
|
(cs/join "\n"
|
||||||
[(yaml/to-string (generate-config my-config my-auth))
|
[(yaml/to-string (generate-config my-config my-auth))
|
||||||
"---"
|
"---"
|
||||||
|
|
|
@ -1,7 +1,12 @@
|
||||||
(ns dda.k8s-mastodon-bot.browser
|
(ns dda.k8s-mastodon-bot.browser
|
||||||
(:require
|
(:require
|
||||||
|
[clojure.spec.alpha :as s]
|
||||||
|
[clojure.spec.test.alpha :as st]
|
||||||
|
[expound.alpha :as expound]
|
||||||
[dda.k8s-mastodon-bot.core :as core]))
|
[dda.k8s-mastodon-bot.core :as core]))
|
||||||
|
|
||||||
|
(set! s/*explain-out* expound/printer)
|
||||||
|
|
||||||
(defn config-from-document []
|
(defn config-from-document []
|
||||||
(-> js/document
|
(-> js/document
|
||||||
(.getElementById "config")
|
(.getElementById "config")
|
||||||
|
@ -25,3 +30,6 @@
|
||||||
(.addEventListener "click"
|
(.addEventListener "click"
|
||||||
#(-> (core/generate (config-from-document) (auth-from-document))
|
#(-> (core/generate (config-from-document) (auth-from-document))
|
||||||
(render-to-document)))))
|
(render-to-document)))))
|
||||||
|
|
||||||
|
|
||||||
|
(st/instrument 'dda.k8s-mastodon-bot.core)
|
||||||
|
|
Loading…
Reference in a new issue