@jvtrigueros that's not currently implemented, but is straightforward with a plugin.
quick untested example:
(ns jvtrigueros.kaocha-plugins
(:require [clojure.string :as str]))
(defn- accumulate [m k v]
(update m k (fnil conj []) v))
(defn- parse-binding [s]
(let [[k & vs] (str/split s #"=")
v (str/join "=" vs)]
[k v]))
(def cli-opts
[nil "--binding" "Configure a dynamic binding, syntax dynamic.var/name=edn-value".
:parse-fn parse-binding
:assoc-fn accumulate])
(defplugin jvtrigueros.kaocha-plugins/cli-bindings
(cli-options [opts]
(conj opts cli-opts))
(config [config]
(let [bindings (get-in config [:kaocha/cli-options :binding])]
(update config :kaocha/bindings #(into (or % {}) bindings)))))
put that under src/
and try it out with kaocha --plugin jvtrigueros.kaocha-plugins/cli-bindings --binding my.var=[1,2,3] --print-config
It would perhaps even be better to just have --binding take an edn map
Sweet! Thanks!
ah and you'll have to :refer [defplugin]
🙂
Lemme give it a shot. Essentially I want to toggle some var when testing locally vs ci
ok, in that case I would also look at the features that aero gives you. e.g. create a tests-ci.edn
, containing #merge #include "tests.edn" {:kaocha/bindings {...}}
and then run bin/kaocha --config-file tests-ci.edn
on CI
actually this makes me think we could do some cool stuff with aero's profiles, having a --profile
cli flag, and defaulting to a profile of :ci
when CI=true
(which travis/circle/... all set)
Ah I didn’t know I could do this. Thanks!