eltonlaw / gorp

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Generate :custom-init to pass into reply.main/launch from function

eltonlaw opened this issue · comments

Something like this should work

(defn generate-custom-init-forms [f]
  (if-let [s (repl/source-fn f)]
    (let [f-source (read-string s)
          f-var-name (second f-source)]
      (cons 'do
            (list
              f-source
              (list f-var-name))))
    (do (println "Failed to get source-fn of" f)
        (System/exit 1))))

but for some reason clojure.repl/source-fn fails to properly resolve init-fn when invoked as main.