]> njoseph.me Git - babashka-scripts.git/blob - scripts/utils.clj
git: minor changes
[babashka-scripts.git] / scripts / utils.clj
1 (ns utils
2 (:require [lib :refer [expand-home run-cmd]]
3 [babashka.process :refer [process]]))
4
5 (defn run-seq
6 "Run a sequence of shell commands on a sequence of arguments.
7
8 Examples:
9
10 1. Play and delete each video from a folder
11 ls | bb -i '(run-seq [\"mpv\" \"rm\"] *input*)'
12 "
13 [commands arguments]
14 (doseq [argument arguments
15 command commands]
16 (println (run-cmd [command argument]))))
17
18 (defn run-task-in-cwd
19 "Run a bb task from this repository in the current working directory."
20 [task]
21 (let [current-dir (System/getenv "PWD")
22 babashka-scripts-dir (expand-home "~/dev/babashka-scripts/")]
23 (print (-> (process ["bb" task current-dir] {:dir babashka-scripts-dir})
24 :out
25 slurp))))