Fork me on GitHub
#mount
<
2015-12-30
>
timgilbert18:12:05

Hi all… I’m trying to figure out how to integrate command-line argument processing with mount, and having some trouble with it

timgilbert18:12:37

My basic idea is that my app starts up and reads a config file config.edn

timgilbert18:12:35

…and then I parse the command-line via tools.cli and override certain values, like maybe I’ve got a --port 3000 command-line option

timgilbert18:12:29

So ideally everything looking for the config, eg the web server, just requires [foo.config :refer [app-config]] to get the config

timgilbert18:12:52

…but I can’t figure out how to set the ns dependency tree up so this is possible

tolitius18:12:48

edited the link.. simple_smile

timgilbert18:12:49

Oh, I totally missed that in the README, sorry

tolitius18:12:10

all good, let me know how it goes, and/or if you have more questions

timgilbert18:12:32

Ok, great. Thanks, that’s exactly what I was wondering about

timgilbert18:12:38

Reading comprehension fail

tolitius18:12:00

nah.. the readme is too large, I might need to organize it a bit better

timgilbert18:12:17

So in this case, I wouldn’t be able to refer to the parsed config from the main ns, right? Otherwise I’d get a circular dependency on config?

tolitius18:12:49

do you mean how to refer to the cli args?

timgilbert18:12:03

I can probably just deal with the processing inside of config, I guess

tolitius18:12:43

this is one way

timgilbert18:12:47

Yeah, so like maybe I define addresses for three deployment environments in the config and the CLI args specify one

timgilbert18:12:23

Ok, right, so the validation would occur when I’m reconciling the args and the file, that makes sense actually

tolitius18:12:26

mount will remember those args, so you can use them to override / create a namespace level config

timgilbert18:12:00

Ok, I think I see how to proceed. Thanks! mount seems like a great library

tolitius18:12:26

great, thanks for the feedback simple_smile let me know how it goes

tolitius18:12:27

btw that branch with the example is from the old mount version, which still makes the example valid, but uses some "older ways", e.g. https://github.com/tolitius/mount/blob/with-args/test/app/config.clj#L2 should be mount.core :refer, etc..