rewrite to hiccup
This commit is contained in:
parent
f7457e64d2
commit
6e58278f9d
1 changed files with 32 additions and 19 deletions
|
|
@ -84,6 +84,17 @@
|
||||||
(def bb-edn
|
(def bb-edn
|
||||||
(atom nil))
|
(atom nil))
|
||||||
|
|
||||||
|
(defn decode-task [task]
|
||||||
|
(let [task-key (first task)
|
||||||
|
args (rest task)
|
||||||
|
maybe-opts (first args)]
|
||||||
|
(if (map? maybe-opts)
|
||||||
|
{:task task-key
|
||||||
|
:opts maybe-opts
|
||||||
|
:args (rest args)}
|
||||||
|
{:task task-key
|
||||||
|
:args args})))
|
||||||
|
|
||||||
(defn print-help [ctx command-line-args]
|
(defn print-help [ctx command-line-args]
|
||||||
(if (empty? command-line-args)
|
(if (empty? command-line-args)
|
||||||
(do
|
(do
|
||||||
|
|
@ -141,8 +152,9 @@ Use -- to separate script command line args from bb command line args.
|
||||||
(let [k (first command-line-args)
|
(let [k (first command-line-args)
|
||||||
k (keyword (subs k 1))
|
k (keyword (subs k 1))
|
||||||
task (get-in @bb-edn [:tasks k])
|
task (get-in @bb-edn [:tasks k])
|
||||||
main (:main task)
|
{:keys [:args]} (decode-task task)
|
||||||
help-text (:task/help task)]
|
main (first args)
|
||||||
|
help-text (:task/help (meta task))]
|
||||||
(if help-text
|
(if help-text
|
||||||
[(println help-text) 0]
|
[(println help-text) 0]
|
||||||
(if main
|
(if main
|
||||||
|
|
@ -558,23 +570,24 @@ Use -- to separate script command line args from bb command line args.
|
||||||
opts))))
|
opts))))
|
||||||
|
|
||||||
(defn resolve-task [task {:keys [:command-line-args]}]
|
(defn resolve-task [task {:keys [:command-line-args]}]
|
||||||
(case (:task/type task)
|
(let [{:keys [:task :opts :args]} (decode-task task)]
|
||||||
|
opts ;; not used
|
||||||
|
(case task
|
||||||
:babashka
|
:babashka
|
||||||
(let [cmd-line-args (get task :task/args)]
|
(let [cmd-line-args args]
|
||||||
(parse-opts (seq (map str (concat cmd-line-args command-line-args)))))
|
(parse-opts (seq (map str (concat cmd-line-args command-line-args)))))
|
||||||
:shell
|
:shell
|
||||||
(let [args (get task :task/args)
|
(let [args (into (vec args) command-line-args)]
|
||||||
args (into (vec args) command-line-args)]
|
|
||||||
{:exec (fn []
|
{:exec (fn []
|
||||||
[nil
|
[nil
|
||||||
(-> (p/process args {:inherit true})
|
(-> (p/process args {:inherit true})
|
||||||
deref
|
deref
|
||||||
:exit)])})
|
:exit)])})
|
||||||
:main
|
:main
|
||||||
(let [main-arg (:main task)
|
(let [main-arg (first args)
|
||||||
cmd-line-args (:task/args task)]
|
cmd-line-args (rest args)]
|
||||||
(parse-opts (seq (map str (concat ["--main" main-arg] cmd-line-args command-line-args)))))
|
(parse-opts (seq (map str (concat ["--main" main-arg] cmd-line-args command-line-args)))))
|
||||||
(error (str "No such task: " (:task/type task)) 1)))
|
(error (str "No such task: " (:task/type task)) 1))))
|
||||||
|
|
||||||
(def should-load-inits?
|
(def should-load-inits?
|
||||||
"if true, then we should still load preloads and user.clj"
|
"if true, then we should still load preloads and user.clj"
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue