From 0b676fd86d477b8da70dd3d8a4a676ae1df6dd47 Mon Sep 17 00:00:00 2001 From: Gert Goet Date: Tue, 7 Feb 2023 18:47:16 +0100 Subject: [PATCH] Use pprint from util --- bbin | 21 +++++++++------------ src/babashka/bbin/scripts.clj | 21 +++++++++------------ 2 files changed, 18 insertions(+), 24 deletions(-) diff --git a/bbin b/bbin index 07fab30..2487893 100755 --- a/bbin +++ b/bbin @@ -277,9 +277,6 @@ WARNING: - Set the BABASHKA_BBIN_BIN_DIR env variable to \"$HOME/.babashka/bbi [selmer.util :as selmer-util]) (:import (java.util.jar JarFile))) -(defn- pprint [x _] - (pprint/pprint x)) - (defn- local-lib-path [script-deps] (let [lib (key (first script-deps)) coords (val (first script-deps))] @@ -521,9 +518,9 @@ WARNING: - Set the BABASHKA_BBIN_BIN_DIR env variable to \"$HOME/.babashka/bbi [path contents dry-run?] (let [path-str (str path)] (if dry-run? - (pprint {:script-file path-str - :script-contents contents} - dry-run?) + (util/pprint {:script-file path-str + :script-contents contents} + dry-run?) (do (spit path-str contents) (when-not util/windows? (sh ["chmod" "+x" path-str])) @@ -535,7 +532,7 @@ WARNING: - Set the BABASHKA_BBIN_BIN_DIR env variable to \"$HOME/.babashka/bbi (let [http-url (:script/lib cli-opts) script-deps {:bbin/url http-url} header {:coords script-deps} - _ (pprint header cli-opts) + _ (util/pprint header cli-opts) script-name (or (:as cli-opts) (http-url->script-name http-url)) script-contents (-> (slurp (:bbin/url script-deps)) (insert-script-header header)) @@ -547,7 +544,7 @@ WARNING: - Set the BABASHKA_BBIN_BIN_DIR env variable to \"$HOME/.babashka/bbi (let [file-path (str (fs/canonicalize (:script/lib cli-opts) {:nofollow-links true})) script-deps {:bbin/url (str "file://" file-path)} header {:coords script-deps} - _ (pprint header cli-opts) + _ (util/pprint header cli-opts) script-name (or (:as cli-opts) (file-path->script-name file-path)) script-contents (-> (slurp file-path) (insert-script-header header)) @@ -578,7 +575,7 @@ WARNING: - Set the BABASHKA_BBIN_BIN_DIR env variable to \"$HOME/.babashka/bbi main-ns (jar->main-ns tmp-jar-path) cached-jar-path (fs/file (util/jars-dir cli-opts) (str script-name ".jar")) _ (fs/move tmp-jar-path cached-jar-path {:replace-existing true}) - _ (pprint header cli-opts) + _ (util/pprint header cli-opts) script-edn-out (with-out-str (binding [*print-namespace-maps* false] (clojure.pprint/pprint header))) @@ -600,7 +597,7 @@ WARNING: - Set the BABASHKA_BBIN_BIN_DIR env variable to \"$HOME/.babashka/bbi main-ns (jar->main-ns file-path) script-deps {:bbin/url (str "file://" file-path)} header {:coords script-deps} - _ (pprint header cli-opts) + _ (util/pprint header cli-opts) script-name (or (:as cli-opts) (file-path->script-name file-path)) cached-jar-path (fs/file (util/jars-dir cli-opts) (str script-name ".jar")) script-edn-out (with-out-str @@ -666,7 +663,7 @@ WARNING: - Set the BABASHKA_BBIN_BIN_DIR env variable to \"$HOME/.babashka/bbi header' (if (#{::no-lib} lib) {:coords {:bbin/url (str "file://" (get-in header [:coords :local/root]))}} header) - _ (pprint header' cli-opts) + _ (util/pprint header' cli-opts) _ (when-not (#{::no-lib} lib) (deps/add-deps {:deps script-deps})) script-root (fs/canonicalize (or (get-in header [:coords :local/root]) @@ -760,7 +757,7 @@ WARNING: - Set the BABASHKA_BBIN_BIN_DIR env variable to \"$HOME/.babashka/bbi (select-keys cli-opts [:mvn/version])} header {:lib (key (first script-deps)) :coords (val (first script-deps))} - _ (pprint header cli-opts) + _ (util/pprint header cli-opts) _ (deps/add-deps {:deps script-deps}) script-root (fs/canonicalize (or (:local/root cli-opts) (local-lib-path script-deps)) {:nofollow-links true}) script-name (or (:as cli-opts) (second (str/split (:script/lib cli-opts) #"/"))) diff --git a/src/babashka/bbin/scripts.clj b/src/babashka/bbin/scripts.clj index 6b18a1f..6376b03 100644 --- a/src/babashka/bbin/scripts.clj +++ b/src/babashka/bbin/scripts.clj @@ -15,9 +15,6 @@ [selmer.util :as selmer-util]) (:import (java.util.jar JarFile))) -(defn- pprint [x _] - (pprint/pprint x)) - (defn- local-lib-path [script-deps] (let [lib (key (first script-deps)) coords (val (first script-deps))] @@ -259,9 +256,9 @@ [path contents dry-run?] (let [path-str (str path)] (if dry-run? - (pprint {:script-file path-str - :script-contents contents} - dry-run?) + (util/pprint {:script-file path-str + :script-contents contents} + dry-run?) (do (spit path-str contents) (when-not util/windows? (sh ["chmod" "+x" path-str])) @@ -273,7 +270,7 @@ (let [http-url (:script/lib cli-opts) script-deps {:bbin/url http-url} header {:coords script-deps} - _ (pprint header cli-opts) + _ (util/pprint header cli-opts) script-name (or (:as cli-opts) (http-url->script-name http-url)) script-contents (-> (slurp (:bbin/url script-deps)) (insert-script-header header)) @@ -285,7 +282,7 @@ (let [file-path (str (fs/canonicalize (:script/lib cli-opts) {:nofollow-links true})) script-deps {:bbin/url (str "file://" file-path)} header {:coords script-deps} - _ (pprint header cli-opts) + _ (util/pprint header cli-opts) script-name (or (:as cli-opts) (file-path->script-name file-path)) script-contents (-> (slurp file-path) (insert-script-header header)) @@ -316,7 +313,7 @@ main-ns (jar->main-ns tmp-jar-path) cached-jar-path (fs/file (util/jars-dir cli-opts) (str script-name ".jar")) _ (fs/move tmp-jar-path cached-jar-path {:replace-existing true}) - _ (pprint header cli-opts) + _ (util/pprint header cli-opts) script-edn-out (with-out-str (binding [*print-namespace-maps* false] (clojure.pprint/pprint header))) @@ -338,7 +335,7 @@ main-ns (jar->main-ns file-path) script-deps {:bbin/url (str "file://" file-path)} header {:coords script-deps} - _ (pprint header cli-opts) + _ (util/pprint header cli-opts) script-name (or (:as cli-opts) (file-path->script-name file-path)) cached-jar-path (fs/file (util/jars-dir cli-opts) (str script-name ".jar")) script-edn-out (with-out-str @@ -404,7 +401,7 @@ header' (if (#{::no-lib} lib) {:coords {:bbin/url (str "file://" (get-in header [:coords :local/root]))}} header) - _ (pprint header' cli-opts) + _ (util/pprint header' cli-opts) _ (when-not (#{::no-lib} lib) (deps/add-deps {:deps script-deps})) script-root (fs/canonicalize (or (get-in header [:coords :local/root]) @@ -498,7 +495,7 @@ (select-keys cli-opts [:mvn/version])} header {:lib (key (first script-deps)) :coords (val (first script-deps))} - _ (pprint header cli-opts) + _ (util/pprint header cli-opts) _ (deps/add-deps {:deps script-deps}) script-root (fs/canonicalize (or (:local/root cli-opts) (local-lib-path script-deps)) {:nofollow-links true}) script-name (or (:as cli-opts) (second (str/split (:script/lib cli-opts) #"/")))