Skip to content

Commit

Permalink
Allow for warmup
Browse files Browse the repository at this point in the history
  • Loading branch information
eval committed Feb 29, 2024
1 parent 9dd6693 commit a91f417
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 28 deletions.
11 changes: 7 additions & 4 deletions src/eval/deps_try.clj
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,10 @@


(defn- start-repl! [{requested-deps :deps
prepare :prepare
{recipe-deps :deps
ns-only :ns-only
recipe-location :location} :recipe :as _args}]
#_(prn ::args args)
(let [default-deps {'org.clojure/clojure {:mvn/version "1.12.0-alpha8"}}
{:keys [cp-file]
default-cp :cp
Expand All @@ -148,6 +148,7 @@
(let [cmd (cond-> ["java" "-classpath" classpath]
(seq jvm-opts) (into jvm-opts)
:always (into ["clojure.main" "-m" "eval.deps-try.try"])
prepare (into ["-P"])
recipe-location (into (if ns-only
["--recipe-ns" recipe-location]
["--recipe" recipe-location])))]
Expand Down Expand Up @@ -219,6 +220,7 @@
{error :error} (util/pred-> (complement :error) parsed-opts
(try-deps/parse-dep-args)
(assoc-possible-recipe parsed-recipe)
(->> (merge parsed-opts))
(start-repl!))]
(when error
(print-error-and-exit! (errors/format-error error)))))
Expand All @@ -245,10 +247,11 @@
:restrict [:refresh :help :plain :color]}
{:cmds []
:fn #'handle-fallback-cmd
:restrict [:version :deps :help :recipe :recipe-ns]
:coerce {:deps [:string]}
:restrict [:version :deps :help :recipe :recipe-ns :print-deps :prepare]
:coerce {:deps [:string] :prepare boolean}
:alias {:h :help
:v :version}
:v :version
:P :prepare}
:exec-args {:deps []} :args->opts (repeat :deps)}])

(defn -main [& args]
Expand Down
50 changes: 26 additions & 24 deletions src/eval/deps_try/try.clj
Original file line number Diff line number Diff line change
Expand Up @@ -157,30 +157,32 @@

(defn -main [& args]
;; via --debug flag?
#_(prn ::args args)
(binding [*debug-log* false]
(let [data-path (fs/xdg-data-home "deps-try")]
(ensure-path-exists! data-path)
(rebel-core/ensure-terminal
(let [repl-opts (cond-> {:deps-try/data-path data-path
#_#_:prompt (fn [] (println (str *ns* "=>"))) ;; when prompt is too deep
:caught (fn [ex]
(persist-just-caught ex)
(clojure.main/repl-caught ex))
:init (fn []
(load-slow-deps!)
(apply require clojure.main/repl-requires)
(set! clojure.core/*print-namespace-maps* false))
:eval (fn [form]
(eval `(do ~(handle-sigint-form)
~(reset-just-caught)
~form)))
:print syntax-highlight-pprint}
(second args) (assoc :deps-try/recipe
(let [recipe (recipe/parse (second args))]
(assoc recipe :ns-only (= (first args) "--recipe-ns")))))]
(repl repl-opts)))
(System/exit 0))))
(let [prepare? (filter #{"-P"} args)]
(if prepare?
(System/exit 0)
(binding [*debug-log* false]
(let [data-path (fs/xdg-data-home "deps-try")]
(ensure-path-exists! data-path)
(rebel-core/ensure-terminal
(let [repl-opts (cond-> {:deps-try/data-path data-path
#_#_:prompt (fn [] (println (str *ns* "=>"))) ;; when prompt is too deep
:caught (fn [ex]
(persist-just-caught ex)
(clojure.main/repl-caught ex))
:init (fn []
(load-slow-deps!)
(apply require clojure.main/repl-requires)
(set! clojure.core/*print-namespace-maps* false))
:eval (fn [form]
(eval `(do ~(handle-sigint-form)
~(reset-just-caught)
~form)))
:print syntax-highlight-pprint}
(second args) (assoc :deps-try/recipe
(let [recipe (recipe/parse (second args))]
(assoc recipe :ns-only (= (first args) "--recipe-ns")))))]
(repl repl-opts)))
(System/exit 0))))))

(comment
(recipe/parse "/Users/gert/projects/deps-try/deps-try-recipes/recipes/next-jdbc/postgresql.clj")
Expand Down

0 comments on commit a91f417

Please sign in to comment.