diff --git a/src/babashka/main.clj b/src/babashka/main.clj index 5973a71d..55a25b84 100644 --- a/src/babashka/main.clj +++ b/src/babashka/main.clj @@ -85,7 +85,10 @@ (atom nil)) (defn decode-task [task] - (let [task-key (first task) + (let [task (if (map? task) + (:task task) + task) + task-key (first task) args (rest task) maybe-opts (first args)] (if (map? maybe-opts) @@ -158,7 +161,7 @@ Use -- to separate script command line args from bb command line args. (if-let [task (get-in @bb-edn [:tasks k])] (let [{:keys [:args] task-key :task} (decode-task task)] - (if-let [help-text (:help (meta task))] + (if-let [help-text (:help task)] [(println help-text) 0] (if-let [main (when (= :main task-key) (first args))] @@ -184,7 +187,7 @@ Use -- to separate script command line args from bb command line args. (println) (doseq [[k v] tasks] (println (str (format fmt k) - (when-let [d (:description (meta v))] + (when-let [d (:description v)] (str " " d))))) (println) (println "Run bb :help to view help of a specific task.") diff --git a/test/babashka/bb_edn_test.clj b/test/babashka/bb_edn_test.clj index 4419df27..db4f7241 100644 --- a/test/babashka/bb_edn_test.clj +++ b/test/babashka/bb_edn_test.clj @@ -106,30 +106,30 @@ (deftest help-task-test (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 - 0. ..."} - [:babashka "-e" "(+ 1 2 3)"]}} + 0. ..." + :task [: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 {:task-1 - ^{:description "Return the sum of 1, 2 and 3." - :help "Usage: bb :cool-task + {: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. ..."} - [:babashka "-e" "(+ 1 2 3)"] + :task [:babashka "-e" "(+ 1 2 3)"] :cool-task-2 - ^{:description "Return the sum of 4, 5 and 6." + {: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. ..."} - [:babashka "-e" "(+ 4 5 6)"]}} +0. ..." + :task [:babashka "-e" "(+ 4 5 6)"]}}} (let [res (apply test-utils/bb nil (map str [:tasks]))] (is (str/includes? res "The following tasks are available:"))