Liking cljdoc? Tell your friends :D

b12n.swiza.sh.core


run-cmdsclj

(run-cmds & [{:keys [ignore-error? dir cmds] :or {ignore-error? true}}])

Run multiple commands with simple api.

Examples:

;; a) Run multiple commands, using the shared dir options (ignore error by default) (run-cmds {:dir "." :cmds ["ls -alt" "find . -type f -iname "*.clj"]})

;; b) Similar to the first usage, but stop on the first error (run-cmds {:dir "." :ignore-error? false :cmds ["ls -alt" "invalid-command" "find . -type f -iname "*.clj"]})

;; c) Run multiple command using that run in start from different directory (ignore error) ;; e.g. don't specify :dir option (run-cmds {:cmds ["ls -alt" "find . -type f -iname "*.clj"]})

;; d) Same as above but stop on first error (run-cmds {:ignore-error? false :cmds ["ls -alt" "find . -type f -iname "*.clj"]})

Run multiple commands with simple api.

Examples:

;; a) Run multiple commands, using the shared `dir` options (ignore error by default)
(run-cmds {:dir "."
           :cmds ["ls -alt"
                  "find . -type f -iname "*.clj"]})

;; b) Similar to the first usage, but stop on the first error
(run-cmds {:dir "."
           :ignore-error? false
           :cmds ["ls -alt"
                  "invalid-command"
                  "find . -type f -iname "*.clj"]})

;; c) Run multiple command using that run in start from different directory (ignore error)
;; e.g. don't specify `:dir` option
(run-cmds {:cmds ["ls -alt"
                  "find . -type f -iname "*.clj"]})

;; d) Same as above but stop on first error
(run-cmds {:ignore-error? false
           :cmds ["ls -alt"
                  "find . -type f -iname "*.clj"]})
sourceraw docstring

sh-cmdclj

(sh-cmd & [{:keys [cmd opts]}])

Execute a single shell command.

(sh-cmd {:cmd ["ls"]})) (sh-cmd {:cmd ["ls"] :opts {:dir (expand-path "~/projects")}}))

Execute a single shell command.

(sh-cmd {:cmd ["ls"]}))
(sh-cmd {:cmd ["ls"]
         :opts {:dir (expand-path "~/projects")}}))
sourceraw docstring

sh-cmdsclj

(sh-cmds commands)

Execute multiple shell command stop on the first error.

Example: ;; Building multiple Clojure projects with Leiningen (sh-cmds [{:cmd ["lein" "deps" ":tree"] :opts {:dir (expand-path "~/apps/swiza/swiza-vault")}} {:cmd ["lein" "deps" ":tree"] :opts {:dir (expand-path "~/apps/swiza/swiza-jenkins")}}])

Execute multiple shell command stop on the first error.

Example:
;; Building multiple Clojure projects with Leiningen
(sh-cmds [{:cmd ["lein" "deps" ":tree"]
         :opts {:dir (expand-path "~/apps/swiza/swiza-vault")}}
        {:cmd ["lein" "deps" ":tree"]
         :opts {:dir (expand-path "~/apps/swiza/swiza-jenkins")}}])
sourceraw docstring

sh-execclj

(sh-exec cmd
         &
         [{:keys [opts success-fn error-fn]
           :or {success-fn identity error-fn identity}}])

Execute a shell command and process the result using the callback style function.

Example: ;; Run the command ls and parse the result on success. (sh-exec ["ls" "-alt"] {:opts {:dir (expand-path ".")} :success-fn (fn [x] (if-let [lines (clojure.string/split x #" ")] (map #(clojure.string/split % #"\s+") (rest lines))))})

Execute a shell command and process the result using the callback style function.

  Example:
  ;; Run the command `ls` and parse the result on success.
  (sh-exec ["ls" "-alt"]
         {:opts {:dir (expand-path ".")}
          :success-fn (fn [x]
                        (if-let [lines (clojure.string/split x #"
")]
                          (map #(clojure.string/split % #"\s+") (rest lines))))})
sourceraw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close