tolitius / mount

managing Clojure and ClojureScript app state since (reset)
Eclipse Public License 1.0
1.22k stars 88 forks source link

Way to pass args to start expressions #87

Closed gleenn closed 7 years ago

gleenn commented 7 years ago

Is there a way to pass i.e. command-line arguments to the start functions? All the examples show the start functions deriving configuration for things like network ports and database credentials from files on disk. This conveniently doesn't show how one would take a port specification from the command-line.

This is what I'm trying to accomplish, or to be told a different way to inject the credentials: (defstate db-connection (fn [credentials] (create-db-conn credentials))) (mount/start [#'db-connection (:credentials cli-args)])

tolitius commented 7 years ago

yes, there is: https://github.com/tolitius/mount/blob/master/doc/runtime-arguments.md#passing-runtime-arguments

Usually such credentials are best kept in config files / Zookeeper / Consul, etc.. Where if you really need command line arguments, you can pass -D arguments from a command line which would be set as system properties, which you can use to auto merge with your config files with something like cprop.

gleenn commented 7 years ago

Thanks, should have dug deeper in the docs.