Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

clojure app config files - spit output of pprint s-expression?

Tags:

clojure

I need config files for a clojure application I'm building. They should be easy enough for a user to modify in a text editor and convenient for my program to read.

I was thinking about serializing s-expressions and using spit to put it into a config file in the users home directory, but I want to pprint the data i spit so it looks a little more friendly to human eyes.

How can I spit the output of pprint in clojure?

Is my thought process correct on using serialized s-expressions as a config file in clojure?

like image 715
joefromct Avatar asked May 31 '13 10:05

joefromct


1 Answers

you have a couple of options. First, pprint accepts an optional writer as a second parameter or you can spit the result of with-out-str: (spit "f.txt" (with-out-str (pprint ..))

I think serialized s-expressions are a reasonable choice as long as they are treated just as data.

like image 69
DanLebrero Avatar answered Oct 22 '22 11:10

DanLebrero