syntax
This commit is contained in:
parent
344ce2dca7
commit
235adfcfe5
2 changed files with 15 additions and 12 deletions
|
|
@ -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 <task> to view help of a specific task.")
|
||||
|
|
|
|||
|
|
@ -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:"))
|
||||
|
|
|
|||
Loading…
Reference in a new issue