piping commands with babashka shell

16-07-25

%

I found the docs unclear at first on how to string together commands like you with with bash pipe oprator "|". as-> worked well for me here.

(defn clean-up-docker-image [version]
  (let [image-id (as->
                  (shell {:out :string} "docker image ls") x
                   (shell {:in (:out x) :out :string} "rg" (subs version 1))
                   (shell {:in (:out x) :out :string} "choose 2")
                   (:out x) (str/split-lines x) (first x))]
    (printf "deleting docker image for version %s with image id %s\n" version image-id)
    (shell "docker" "image" "rm" image-id)))

- [ clojurebabashka]

all snippets