List tasks test
This commit is contained in:
parent
0ae56e7098
commit
36abd4152a
2 changed files with 32 additions and 11 deletions
|
|
@ -122,20 +122,19 @@
|
||||||
(let [names (keys tasks)
|
(let [names (keys tasks)
|
||||||
raw-names (filter symbol? names)
|
raw-names (filter symbol? names)
|
||||||
names (map str raw-names)
|
names (map str raw-names)
|
||||||
names (sort names)
|
names (remove #(str/starts-with? % "-") names)
|
||||||
|
names (remove #(:private (get tasks (symbol %))) names)
|
||||||
longest (apply max (map count names))
|
longest (apply max (map count names))
|
||||||
fmt (str "%1$-" longest "s")]
|
fmt (str "%1$-" longest "s")]
|
||||||
(println "The following tasks are available:")
|
(println "The following tasks are available:")
|
||||||
(println)
|
(println)
|
||||||
(doseq [k raw-names
|
(doseq [k names
|
||||||
:let [task (get tasks k)]]
|
:let [task (get tasks (symbol k))]]
|
||||||
(when-not (or (str/starts-with? k "-")
|
(let [task (if (qualified-symbol? task)
|
||||||
(:private task))
|
{:doc (format "Runs %s. See `bb doc %s` for more info." task task)}
|
||||||
(let [task (if (qualified-symbol? task)
|
task)]
|
||||||
{:doc (format "Runs %s. See `bb doc %s` for more info." task task)}
|
(println (str (format fmt k)
|
||||||
task)]
|
(when-let [d (:doc task)]
|
||||||
(println (str (format fmt k)
|
(str " " d)))))))
|
||||||
(when-let [d (:doc task)]
|
|
||||||
(str " " d))))))))
|
|
||||||
(println "No tasks found."))))
|
(println "No tasks found."))))
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -51,6 +51,28 @@
|
||||||
(bb "foo")
|
(bb "foo")
|
||||||
(is (= "quux\nbaz\nbar\nfoo\n" (slurp out))))))
|
(is (= "quux\nbaz\nbar\nfoo\n" (slurp out))))))
|
||||||
|
|
||||||
|
(deftest list-tasks-test
|
||||||
|
(test-utils/with-config {}
|
||||||
|
(let [res (test-utils/bb nil "tasks")]
|
||||||
|
(is (str/includes? res "No tasks found."))))
|
||||||
|
(test-utils/with-config {:tasks {'task1
|
||||||
|
{:doc "task1 doc"
|
||||||
|
:task '(+ 1 2 3)}
|
||||||
|
'task2
|
||||||
|
{:doc "task2 doc"
|
||||||
|
:task '(+ 4 5 6)}
|
||||||
|
'-task3
|
||||||
|
{:task '(+ 1 2 3)}
|
||||||
|
'task4
|
||||||
|
{:task '(+ 1 2 3)
|
||||||
|
:private true}}}
|
||||||
|
(let [res (test-utils/bb nil "tasks")]
|
||||||
|
(is (str/includes? res "The following tasks are available:"))
|
||||||
|
(is (str/includes? res "task1 task1 doc"))
|
||||||
|
(is (str/includes? res "task2 task2 doc"))
|
||||||
|
(is (not (str/includes? res "task3")))
|
||||||
|
(is (not (str/includes? res "task4"))))))
|
||||||
|
|
||||||
;; TODO:
|
;; TODO:
|
||||||
;; Do we want to support the same parsing as the clj CLI?
|
;; Do we want to support the same parsing as the clj CLI?
|
||||||
;; Or do we want `--aliases :foo:bar`
|
;; Or do we want `--aliases :foo:bar`
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue