Add sorting and task/description

This commit is contained in:
Michiel Borkent 2021-03-23 11:15:01 +01:00
parent b69ec8fc17
commit 6abe9a6851
2 changed files with 13 additions and 10 deletions

View file

@ -157,13 +157,14 @@ Use -- to separate script command line args from bb command line args.
,) ;; end defn ,) ;; end defn
(defn print-tasks [tasks] (defn print-tasks [tasks]
(let [tasks (into (sorted-map) tasks)]
(println "The following tasks are available:") (println "The following tasks are available:")
(println) (println)
(doseq [k (keys tasks)] (doseq [[k v] tasks]
(println k)) (println k (:task/description 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]))
(defn print-describe [] (defn print-describe []
(println (println

View file

@ -123,12 +123,14 @@ Addition is a pretty advanced topic. Let us start with the identity element
(deftest list-tasks-test (deftest list-tasks-test
(with-config {:tasks {:cool-task-1 {:task/type :babashka (with-config {:tasks {:cool-task-1 {:task/type :babashka
:args ["-e" "(+ 1 2 3)"] :args ["-e" "(+ 1 2 3)"]
:task/description "Return the sum of 1, 2 and 3."
:task/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 :cool-task-2 {:task/type :babashka
:args ["-e" "(+ 1 2 3)"] :task/description "Return the sum of 4, 5 and 6."
:args ["-e" "(+ 4 5 6)"]
:task/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
@ -136,8 +138,8 @@ Addition is a pretty advanced topic. Let us start with the identity element
(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:"))
(is (str/includes? res ":cool-task-1")) (is (str/includes? res ":cool-task-1 Return the"))
(is (str/includes? res ":cool-task-2"))))) (is (str/includes? res ":cool-task-2 Return the")))))
(deftest main-task-test (deftest main-task-test
(with-config {:paths ["test-resources/task_scripts"] (with-config {:paths ["test-resources/task_scripts"]