 
 ;; run
 
+(defn- emit-start [load-builds-from accumulate-stages-for-pipelines pipeline-stages]
+  (println "Looking at pipeline groups" (distinct (map :group pipeline-stages)))
+  (println "Syncing all builds starting from" (tf/unparse (:date-time tf/formatters) load-builds-from))
+  (when (some? accumulate-stages-for-pipelines)
+    (println "Aggregating jobs for stages of" accumulate-stages-for-pipelines))
+
+  (println "Finding all builds for syncing...")
+
+  pipeline-stages)
+
+(defn- emit-count-items [builds]
+  (println (format "Found %s builds to be synced, starting" (count builds)))
+  builds)
+
+(defn- emit-end [builds]
+  (println)
+  (println (format "Done, wrote %s build entries" (count builds))))
+
 (defn -main [& c-args]
   (def args (parse-opts c-args cli-options))
 

    (assoc job :inputs inputs)))


(defn select-stages [stages filter-groups]
  (if (seq filter-groups)
    (filter #(contains? filter-groups (:group %)) stages)
    stages))


  (let [load-builds-from (get-start-date (:load-builds-from (:options args)))
        accumulate-stages-for-pipelines (set (:aggregate-jobs-for-pipelines (:options args)))
        selected-pipeline-group-names (set (drop 1 (:arguments args)))]

    (->> (goapi/get-stages go-url)
         (select-stages selected-pipeline-group-names)
         (emit-start load-builds-from accumulate-stages-for-pipelines)
         (mapcat (partial job-instances-for-stage load-builds-from accumulate-stages-for-pipelines))
         (sort-by :scheduledDateTime)
         emit-count-items
         (map augment-job-with-inputs)
         (map job-data-for-instance)
         (filter #(some? (:build %)))
         (map augment-job-instance-with-junit-xml)
         (map make-build-instance)
         (map put-to-buildviz)
         emit-end)))
