This commit is contained in:
Michiel Borkent 2021-03-16 10:56:03 +01:00
parent 1f1b6cfde1
commit 57aaed524d

View file

@ -2,6 +2,7 @@
{:no-doc true} {:no-doc true}
(:refer-clojure :exclude [error-handler]) (:refer-clojure :exclude [error-handler])
(:require (:require
[babashka.fs :as fs]
[babashka.impl.bencode :refer [bencode-namespace]] [babashka.impl.bencode :refer [bencode-namespace]]
[babashka.impl.cheshire :refer [cheshire-core-namespace]] [babashka.impl.cheshire :refer [cheshire-core-namespace]]
[babashka.impl.classes :as classes] [babashka.impl.classes :as classes]
@ -179,6 +180,7 @@
(let [options (next options)] (let [options (next options)]
(recur (next options) (recur (next options)
(assoc opts-map :main (first options)))) (assoc opts-map :main (first options))))
;; fallback
(if (some opts-map [:file :jar :socket-repl :expressions :main]) (if (some opts-map [:file :jar :socket-repl :expressions :main])
(assoc opts-map (assoc opts-map
:command-line-args options) :command-line-args options)
@ -189,10 +191,12 @@
(-> opts-map (-> opts-map
(update :expressions (fnil conj []) (first options)) (update :expressions (fnil conj []) (first options))
(assoc :command-line-args (next options))) (assoc :command-line-args (next options)))
(assoc opts-map (if (fs/exists? opt)
(if (str/ends-with? opt ".jar") (assoc opts-map
:jar :file) opt (if (str/ends-with? opt ".jar")
:command-line-args (next options))))))) :jar :file) opt
:command-line-args (next options))
(throw (Exception. (str "File does not exist: " opt)))))))))
opts-map))] opts-map))]
opts)) opts))