Foo
This commit is contained in:
parent
18219526e2
commit
23834a5302
3 changed files with 22 additions and 15 deletions
|
|
@ -5,8 +5,12 @@
|
|||
|
||||
(declare resolve-task)
|
||||
|
||||
(defn error [msg exit]
|
||||
(binding [*out* *err*]
|
||||
(println msg)
|
||||
{:exit-code exit}))
|
||||
|
||||
(defn parse-opts [options]
|
||||
(prn :options options)
|
||||
(let [opts (loop [options options
|
||||
opts-map {}]
|
||||
(if options
|
||||
|
|
@ -129,7 +133,7 @@
|
|||
:command-line-args (next options))
|
||||
(if (str/starts-with? opt ":")
|
||||
(resolve-task opt {:command-line-args (next options)})
|
||||
(throw (Exception. (str "File does not exist: " opt))))))))))
|
||||
(error (str "File does not exist: " opt) 1))))))))
|
||||
opts-map))]
|
||||
opts))
|
||||
|
||||
|
|
@ -142,5 +146,5 @@
|
|||
(let [cmd-line-args (get task :babashka/args)]
|
||||
;; this is for invoking babashka itself with command-line-args
|
||||
(parse-opts (seq (concat cmd-line-args command-line-args))))
|
||||
(throw (Exception. (str "No such task: " task)))))
|
||||
(throw (Exception. (str "File does not exist: " task))))))
|
||||
(error (str "No such task: " task) 1)))
|
||||
(error (str "File does not exist: " task) 1))))
|
||||
|
|
|
|||
|
|
@ -371,7 +371,8 @@ Use -- to separate script command line args from bb command line args.
|
|||
:repl :socket-repl :nrepl
|
||||
:verbose? :classpath
|
||||
:main :uberscript :describe?
|
||||
:jar :uberjar :clojure :task] :as opts}
|
||||
:jar :uberjar :clojure :task
|
||||
:exit-code] :as opts}
|
||||
(cli/parse-opts args)
|
||||
_ (when clojure
|
||||
(if-let [proc (deps/clojure (:opts opts))]
|
||||
|
|
@ -457,15 +458,16 @@ Use -- to separate script command line args from bb command line args.
|
|||
_ (vreset! common/ctx sci-ctx)
|
||||
preloads (some-> (System/getenv "BABASHKA_PRELOADS") (str/trim))
|
||||
[expressions exit-code]
|
||||
(cond expressions [expressions nil]
|
||||
main [[(format "(ns user (:require [%1$s])) (apply %1$s/-main *command-line-args*)"
|
||||
main)] nil]
|
||||
file (try [[(read-file file)] nil]
|
||||
(catch Exception e
|
||||
(error-handler e {:expression expressions
|
||||
:verbose? verbose?
|
||||
:preloads preloads
|
||||
:loader (:loader @cp/cp-state)}))))
|
||||
(if exit-code [nil exit-code]
|
||||
(cond expressions [expressions nil]
|
||||
main [[(format "(ns user (:require [%1$s])) (apply %1$s/-main *command-line-args*)"
|
||||
main)] nil]
|
||||
file (try [[(read-file file)] nil]
|
||||
(catch Exception e
|
||||
(error-handler e {:expression expressions
|
||||
:verbose? verbose?
|
||||
:preloads preloads
|
||||
:loader (:loader @cp/cp-state)})))))
|
||||
expression (str/join " " expressions) ;; this might mess with the locations...
|
||||
exit-code
|
||||
;; handle preloads
|
||||
|
|
|
|||
|
|
@ -1 +1,2 @@
|
|||
{:tasks {:eval-plus {:babashka/args ["-e" "(+ 1 2 3)"]}}}
|
||||
{:tasks {:eval-plus {:babashka/args ["-e" "(+ 1 2 3)"]}
|
||||
:tree {:babashka/args [":clojure" "-Stree"]}}}
|
||||
|
|
|
|||
Loading…
Reference in a new issue