From 7626d912b9f2d729f3c010d97ba2796fcd514e7f Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Thu, 11 Aug 2022 16:23:42 +0200 Subject: [PATCH] :tada: Add srepl helpers for run and print available tasks --- backend/src/app/srepl/main.clj | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/backend/src/app/srepl/main.clj b/backend/src/app/srepl/main.clj index ef3dd336c..685adfdf4 100644 --- a/backend/src/app/srepl/main.clj +++ b/backend/src/app/srepl/main.clj @@ -9,7 +9,24 @@ #_:clj-kondo/ignore (:require [app.common.logging :as l] + [app.common.pprint :as p] + [app.srepl.fixes :as f] [app.srepl.helpers :as h] - [app.srepl.fixes :as f])) + [clojure.pprint :refer [pprint]])) ;; Empty namespace as main entry point for Server REPL + +(defn print-available-tasks + [system] + (let [tasks (:app.worker/registry system)] + (p/pprint (keys tasks) :level 200))) + + +(defn run-task! + ([system name] + (run-task! system name {})) + ([system name params] + (let [tasks (:app.worker/registry system)] + (if-let [task-fn (get tasks name)] + (task-fn params) + (l/warn :hint "no task found" :name name)))))