From 55be656d822a10d265d167a7540a71e86f037f85 Mon Sep 17 00:00:00 2001 From: Michiel Borkent Date: Thu, 25 Mar 2021 12:06:20 +0100 Subject: [PATCH] list tasks --- src/babashka/main.clj | 2 +- test/babashka/bb_edn_test.clj | 33 +++++++++++++++++---------------- 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/src/babashka/main.clj b/src/babashka/main.clj index 2deea69d..15cfc0c5 100644 --- a/src/babashka/main.clj +++ b/src/babashka/main.clj @@ -173,7 +173,7 @@ Use -- to separate script command line args from bb command line args. (println "The following tasks are available:") (println) (doseq [[k v] tasks] - (println k (:task/description v))) + (println k (:description (meta v)))) (println) (println "Run bb :help to view help of a specific task.") [nil 0])) diff --git a/test/babashka/bb_edn_test.clj b/test/babashka/bb_edn_test.clj index 3b2dd55c..5d9ff419 100644 --- a/test/babashka/bb_edn_test.clj +++ b/test/babashka/bb_edn_test.clj @@ -16,7 +16,8 @@ (defmacro with-config [cfg & body] `(let [temp-dir# (fs/create-temp-dir) bb-edn-file# (fs/file temp-dir# "bb.edn")] - (spit bb-edn-file# ~cfg) + (binding [*print-meta* true] + (spit bb-edn-file# ~cfg)) (binding [test-utils/*bb-edn-path* (str bb-edn-file#)] ~@body))) @@ -93,31 +94,31 @@ (is (= 6 (bb :describe))))) (deftest help-task-test - (with-config "{:tasks {:cool-task - ^{:help \"Usage: bb :cool-task + (with-config {:tasks {:cool-task + ^{:help "Usage: bb :cool-task - Addition is a pretty advanced topic. Let us start with the identity element - 0. ...\"} - [:babashka -e (+ 1 2 3)]}}" + Addition is a pretty advanced topic. Let us start with the identity element + 0. ..."} + [:babashka "-e" "(+ 1 2 3)"]}} (is (str/includes? (apply test-utils/bb nil (map str [:help :cool-task])) "Usage: bb :cool-task")))) -#_(deftest list-tasks-test - (with-config {:tasks {:cool-task-1 {:task/type :babashka - :task/args ["-e" "(+ 1 2 3)"] - :task/description "Return the sum of 1, 2 and 3." - :task/help "Usage: bb :cool-task +(deftest list-tasks-test + (with-config {:tasks {:cool-task-1 + ^{:description "Return the sum of 1, 2 and 3." + :help "Usage: bb :cool-task Addition is a pretty advanced topic. Let us start with the identity element 0. ..."} - :cool-task-2 {:task/type :babashka - :task/description "Return the sum of 4, 5 and 6." - :task/args ["-e" "(+ 4 5 6)"] - :task/help "Usage: bb :cool-task + [:babashka "-e" "(+ 1 2 3)"] + :cool-task-2 + ^{:description "Return the sum of 4, 5 and 6." + :help "Usage: bb :cool-task Addition is a pretty advanced topic. Let us start with the identity element -0. ..."}}} +0. ..."} + [:babashka "-e" "(+ 4 5 6)"]}} (let [res (apply test-utils/bb nil (map str [:tasks]))] (is (str/includes? res "The following tasks are available:"))