list tasks

This commit is contained in:
Michiel Borkent 2021-03-25 12:06:20 +01:00
parent a3f7cebd15
commit 55be656d82
2 changed files with 18 additions and 17 deletions

View file

@ -173,7 +173,7 @@ Use -- to separate script command line args from bb command line args.
(println "The following tasks are available:") (println "The following tasks are available:")
(println) (println)
(doseq [[k v] tasks] (doseq [[k v] tasks]
(println k (:task/description v))) (println k (:description (meta v))))
(println) (println)
(println "Run bb :help <task> to view help of a specific task.") (println "Run bb :help <task> to view help of a specific task.")
[nil 0])) [nil 0]))

View file

@ -16,7 +16,8 @@
(defmacro with-config [cfg & body] (defmacro with-config [cfg & body]
`(let [temp-dir# (fs/create-temp-dir) `(let [temp-dir# (fs/create-temp-dir)
bb-edn-file# (fs/file temp-dir# "bb.edn")] 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#)] (binding [test-utils/*bb-edn-path* (str bb-edn-file#)]
~@body))) ~@body)))
@ -93,31 +94,31 @@
(is (= 6 (bb :describe))))) (is (= 6 (bb :describe)))))
(deftest help-task-test (deftest help-task-test
(with-config "{:tasks {:cool-task (with-config {:tasks {:cool-task
^{:help \"Usage: bb :cool-task ^{:help "Usage: bb :cool-task
Addition is a pretty advanced topic. Let us start with the identity element Addition is a pretty advanced topic. Let us start with the identity element
0. ...\"} 0. ..."}
[:babashka -e (+ 1 2 3)]}}" [:babashka "-e" "(+ 1 2 3)"]}}
(is (str/includes? (apply test-utils/bb nil (is (str/includes? (apply test-utils/bb nil
(map str [:help :cool-task])) (map str [:help :cool-task]))
"Usage: bb :cool-task")))) "Usage: bb :cool-task"))))
#_(deftest list-tasks-test (deftest list-tasks-test
(with-config {:tasks {:cool-task-1 {:task/type :babashka (with-config {:tasks {:cool-task-1
:task/args ["-e" "(+ 1 2 3)"] ^{:description "Return the sum of 1, 2 and 3."
:task/description "Return the sum of 1, 2 and 3." :help "Usage: bb :cool-task
:task/help "Usage: bb :cool-task
Addition is a pretty advanced topic. Let us start with the identity element Addition is a pretty advanced topic. Let us start with the identity element
0. ..."} 0. ..."}
:cool-task-2 {:task/type :babashka [:babashka "-e" "(+ 1 2 3)"]
:task/description "Return the sum of 4, 5 and 6." :cool-task-2
:task/args ["-e" "(+ 4 5 6)"] ^{:description "Return the sum of 4, 5 and 6."
:task/help "Usage: bb :cool-task :help "Usage: bb :cool-task
Addition is a pretty advanced topic. Let us start with the identity element 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 (let [res (apply test-utils/bb nil
(map str [:tasks]))] (map str [:tasks]))]
(is (str/includes? res "The following tasks are available:")) (is (str/includes? res "The following tasks are available:"))