 (ns lambdacd.steps.control-flow
-  "control flow elements for a pipeline: steps that control the way their child-steps are being run"
+  "Control-flow elements for a pipeline: steps that control the way their child-steps are being run."
   (:require [lambdacd.execution.core :as execution]
             [clojure.core.async :as async]
             [lambdacd.steps.support :as support]

    (add-watch source key #(reset! target %4))
    key))

(defn ^{:display-type :parallel} either [& steps]
  (fn [args ctx]
    (let [parent-kill-switch (:is-killed ctx)
          kill-switch        (atom false)

                             :is-killed (:is-killed ctx))))


(defn ^{:display-type :container} run
  "Build step that executes its children in sequence and returns once the last step finished.
  Commonly used to pass a chain of steps to into a control flow expecting only one (e.g. `either`, `junction`) or
  to wrap related steps into a container and `alias` it to structure the pipeline.

  Example:
  ```clojure
  (def pipeline-structure
    `(; ...
      (alias \"tests\"
        (run
          unit-test
          acceptance-test))
      (junction
        should-deploy?
        (run
          deploy-ci
          deploy-qa)
        do-nothing)))
  ```
  "
  [ & steps]
  (fn [args ctx]
    (run-steps-in-sequence args ctx steps)))

